New DecodeToken request.
This commit is contained in:
parent
a441431e05
commit
00c202a63a
@ -83,4 +83,26 @@ class AuthD::Request
|
||||
end
|
||||
end
|
||||
AuthD.requests << BootstrapFirstAdmin
|
||||
|
||||
IPC::JSON.message DecodeToken, 14 do
|
||||
property token : String
|
||||
|
||||
def initialize(@token)
|
||||
end
|
||||
|
||||
def handle(authd : AuthD::Service, fd : Int32)
|
||||
logged_user = authd.get_logged_user_full? fd
|
||||
return Response::ErrorMustBeAuthenticated.new if logged_user.nil?
|
||||
logged_user.assert_permission("authd", "*", User::PermissionLevel::Read)
|
||||
|
||||
token_payload = AuthD::Token.from_s authd.configuration.secret_key, token
|
||||
user = authd.users_per_uid.get? token_payload.uid.to_s
|
||||
if user
|
||||
Response::User.new user.to_public
|
||||
else
|
||||
Response::ErrorUserNotFound.new
|
||||
end
|
||||
end
|
||||
end
|
||||
AuthD.requests << DecodeToken
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user