Recording user registration and last connection dates.
This commit is contained in:
parent
bd68148924
commit
189e22902e
18
src/main.cr
18
src/main.cr
@ -60,8 +60,12 @@ class AuthD::Service
|
||||
return Response::Error.new "invalid credentials"
|
||||
end
|
||||
|
||||
user.date_last_connection = Time.local
|
||||
token = user.to_token
|
||||
|
||||
# change the date of the last connection
|
||||
@users_per_uid.update user.uid.to_s, user
|
||||
|
||||
Response::Token.new token.to_s @jwt_key
|
||||
when Request::AddUser
|
||||
# No verification of the users' informations when an admin adds it.
|
||||
@ -90,6 +94,9 @@ class AuthD::Service
|
||||
user.profile = profile
|
||||
end
|
||||
|
||||
# We consider adding the user as a registration
|
||||
user.date_registration = Time.local
|
||||
|
||||
@users << user
|
||||
|
||||
Response::UserAdded.new user.to_public
|
||||
@ -129,6 +136,11 @@ class AuthD::Service
|
||||
return Response::Error.new "invalid credentials"
|
||||
end
|
||||
|
||||
user.date_last_connection = Time.local
|
||||
|
||||
# change the date of the last connection
|
||||
@users_per_uid.update user.uid.to_s, user
|
||||
|
||||
Response::User.new user.to_public
|
||||
when Request::GetUser
|
||||
uid_or_login = request.user
|
||||
@ -209,8 +221,7 @@ class AuthD::Service
|
||||
user.profile = profile
|
||||
end
|
||||
|
||||
|
||||
@users << user
|
||||
user.date_registration = Time.local
|
||||
|
||||
# Once the user is created and stored, we try to contact him
|
||||
unless Process.run("activation-mailer", [
|
||||
@ -223,6 +234,9 @@ class AuthD::Service
|
||||
return Response::Error.new "cannot contact the user (but still registered)"
|
||||
end
|
||||
|
||||
# add the user only if we were able to send the confirmation mail
|
||||
@users << user
|
||||
|
||||
Response::UserAdded.new user.to_public
|
||||
when Request::UpdatePassword
|
||||
user = @users_per_login.get? request.login
|
||||
|
@ -43,6 +43,8 @@ class AuthD::User
|
||||
# service => resource => permission level
|
||||
property permissions : Hash(String, Hash(String, PermissionLevel))
|
||||
property configuration : Hash(String, Hash(String, JSON::Any))
|
||||
property date_last_connection : Time? = nil
|
||||
property date_registration : Time? = nil
|
||||
|
||||
def to_token
|
||||
Token.new @login, @uid
|
||||
|
Loading…
Reference in New Issue
Block a user