Class: CommandTower::LoginStrategy::PlainText::Create
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- CommandTower::LoginStrategy::PlainText::Create
- Defined in:
- app/services/command_tower/login_strategy/plain_text/create.rb
Constant Summary collapse
- EASY_GETTER =
CommandTower.config.login.plain_text
Constants inherited from ServiceBase
ServiceBase::ON_ARGUMENT_VALIDATION
Instance Method Summary collapse
Methods inherited from ServiceBase
inherited, #internal_validate, #service_base_logging, #validate!
Methods included from ArgumentValidation
Methods included from ServiceLogging
#aletered_message, #class_name, #log, #log_error, #log_info, #log_prefix, #log_warn, #logger, #service_id
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/command_tower/login_strategy/plain_text/create.rb', line 16 def call unless email =~ URI::MailTo::EMAIL_REGEXP inline_argument_failure!(errors: { email: "Invalid email address" }) end username_validity = CommandTower::Username::Available.(username:) if !username_validity.valid inline_argument_failure!(errors: { username: "Username is invalid. #{CommandTower.config.username.}" }) end user = User.new( first_name:, last_name:, username:, email:, password:, password_confirmation:, ) if user.save context.user = user CommandTower::InboxService::Blast::NewUserBlaster.(user:) else inline_argument_failure!(errors: user.errors) end end |