Added option to not check LDAP to create_user
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Dominic Grimm 2022-02-06 19:32:22 +01:00
parent 1780a1d0b7
commit 569d9488ae

View file

@ -19,14 +19,14 @@ module Backend
end
@[GraphQL::Field]
def create_user(context : Context, input : UserCreateInput) : User
def create_user(context : Context, input : UserCreateInput, check_ldap : Bool = true) : User
context.admin!
raise "LDAP user does not exist" unless begin
!!Ldap.user(Ldap.uid(input.username))
rescue LDAP::Client::AuthError
false
end
raise "LDAP user does not exist" if check_ldap && begin
!Ldap.user(Ldap.uid(input.username))
rescue LDAP::Client::AuthError
true
end
user = Db::User.create!(username: input.username, role: input.role.to_s)
User.new(user)