Added update password method
This commit is contained in:
parent
d7599a03af
commit
192e8b632f
|
@ -15,6 +15,22 @@ module MW
|
|||
)
|
||||
end
|
||||
|
||||
@[GraphQL::Field]
|
||||
def update_password(context : Context, password : String) : LoginPayload
|
||||
context.authenticated!
|
||||
|
||||
if Auth.verify_password?(password, context.user.not_nil!.password)
|
||||
raise "New password must be different from old password"
|
||||
end
|
||||
|
||||
context.user.not_nil!.update!(password: Auth.hash_password(password))
|
||||
|
||||
LoginPayload.new(
|
||||
user: User.new(context.user.not_nil!),
|
||||
token: Auth.create_user_jwt(context.user.not_nil!.id.not_nil!.to_i),
|
||||
)
|
||||
end
|
||||
|
||||
@[GraphQL::Field]
|
||||
def create_user(context : Context, input : UserCreateInput) : User
|
||||
context.admin!
|
||||
|
|
Loading…
Reference in a new issue