Recording user registration and last connection dates.

ipc07
Philippe PITTOLI 2020-03-23 06:54:45 +01:00
parent bd68148924
commit 189e22902e
2 changed files with 23 additions and 7 deletions

View File

@ -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

View File

@ -37,12 +37,14 @@ class AuthD::User
property profile : JSON::Any?
# Private.
property contact : Contact
property password_hash : String
property password_renew_key : String?
property contact : Contact
property password_hash : String
property password_renew_key : String?
# service => resource => permission level
property permissions : Hash(String, Hash(String, PermissionLevel))
property configuration : Hash(String, Hash(String, JSON::Any))
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