public async Task <AuthenticationTicket> OnAuthenticatedAsync( long ticketId, ulong userId, string username, string discriminator, string avatarHash, IReadOnlyDictionary <int, string> grantedPermissions, CancellationToken cancellationToken) { AuthenticationLogMessages.AuthenticationPerforming(_logger, ticketId, userId, username, discriminator, avatarHash, grantedPermissions); AuthenticationLogMessages.AuthenticationTicketActiveIdFetching(_logger, userId); var activeTicketId = await GetActiveTicketIdAsync(userId, cancellationToken); AuthenticationLogMessages.AuthenticationTicketActiveIdFetched(_logger, activeTicketId); if (activeTicketId != ticketId) { AuthenticationLogMessages.GrantedPermissionsFetching(_logger, userId); grantedPermissions = (await _usersService.GetGrantedPermissionsAsync( userId, cancellationToken)) .Value .ToDictionary(x => x.Id, x => x.Name); AuthenticationLogMessages.GrantedPermissionsFetched(_logger, grantedPermissions); } _currentTicket = new AuthenticationTicket( activeTicketId, userId, username, discriminator, avatarHash, grantedPermissions); AuthenticationLogMessages.AuthenticationPerformed(_logger, activeTicketId); return(_currentTicket); }