Пример #1
0
        public static int GetUserType(string token)
        {
            if (TokenProcessor.VerifyToken(token))
            {
                var sql = "SELECT user.UserType " +
                          "FROM user " +
                          "INNER JOIN authentication_token " +
                          "ON user.Id = authentication_token.UserId " +
                          $"WHERE Token = '{token}' ";

                var user = SqlDataAccess.LoadData <UserModel>(sql);

                if (user != null)
                {
                    return(user[0].UserType);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                return(-1);
            }
        }
Пример #2
0
        private string GenerateUserToken()
        {
            Token = TokenProcessor.GenerateToken();

            while (VerifyToken(Token))
            {
                Token = TokenProcessor.GenerateToken();
            }

            UserRole = TokenProcessor.WriteAuthenticationToken(User.Id, Token);

            return(Token);
        }
Пример #3
0
 public static bool VerifyToken(string token)
 {
     return(TokenProcessor.VerifyToken(token) ? true : false);
 }