Class: Foobara::Auth::Register

Inherits:
Command
  • Object
show all
Defined in:
foobara-auth-0.1.1/src/register.rb

Overview

TODO: should raise error if username or email already in use!

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Command

install!

Methods included from TruncatedInspect

#inspect, truncating

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Instance Attribute Details

#userObject

Returns the value of attribute user.



28
29
30
# File 'src/register.rb', line 28

def user
  @user
end

Instance Method Details

#create_userObject



30
31
32
33
34
35
36
37
38
# File 'src/register.rb', line 30

def create_user
  inputs = { username:, email: }

  if user_id
    inputs[:user_id] = user_id
  end

  self.user = run_subcommand!(CreateUser, inputs)
end

#executeObject



18
19
20
21
22
23
24
25
26
# File 'src/register.rb', line 18

def execute
  create_user

  if password?
    set_password
  end

  user
end

#password?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'src/register.rb', line 40

def password?
  plaintext_password && !plaintext_password.empty?
end

#set_passwordObject



44
45
46
# File 'src/register.rb', line 44

def set_password
  run_subcommand!(SetPassword, user:, plaintext_password:)
end