public static AuthToken Create(string role, string password)
 {
     return(new AuthToken
     {
         Role = role,
         Token = HashCalculator.Calculate(password)
     });
 }
Esempio n. 2
0
        public Permissions ValidateToken(AuthToken token)
        {
            var passwords = _rolesProvider.GetRoles(token.Role);
            var role      = passwords.FirstOrDefault(x => HashCalculator.Calculate(x.Password) == token.Token);

            if (role != null)
            {
                return(new Permissions
                {
                    AllowMessages = role.Messages,
                    AllowInvites = role.Invites,
                    AllowFindFriends = role.FindFriends,
                    AllowInstruments = role.Instruments
                });
            }

            return(null);
        }