Move user db creation to service
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
class CreateAccount < ApplicationService
|
||||
def initialize(args)
|
||||
@username = args[:username]
|
||||
@email = args[:email]
|
||||
@password = args[:password]
|
||||
@username = args[:username]
|
||||
@domain = args[:ou] || "kosmos.org"
|
||||
@email = args[:email]
|
||||
@password = args[:password]
|
||||
@invitation = args[:invitation]
|
||||
end
|
||||
|
||||
def call
|
||||
create_user_in_database
|
||||
add_ldap_document
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_user_in_database
|
||||
User.create!(
|
||||
cn: @username,
|
||||
ou: @domain,
|
||||
email: @email,
|
||||
password: @password,
|
||||
password_confirmation: @password
|
||||
)
|
||||
end
|
||||
|
||||
def add_ldap_document
|
||||
dn = "cn=#{@username},ou=kosmos.org,cn=users,dc=kosmos,dc=org"
|
||||
attr = {
|
||||
|
||||
Reference in New Issue
Block a user