Esempio n. 1
0
        public User Login(string userName, string password)
        {
            if (userDb.CheckUserName(userName))
            {
                string salt           = userDb.GetSalt(userName);
                string hashedPassword = Security.GetHashedPassword(password, salt);

                User user = userDb.Login(userName, hashedPassword);

                Token token = null;

                if (user != null)
                {
                    token = new Token
                    {
                        SecureToken = Security.CreateToken(100),
                        UserName    = user.UserName,
                        CreateDate  = DateTime.Now
                    };

                    user.LoginToken = token;

                    if (tokenCtrl.InsertToken(token))
                    {
                        return(user);
                    }
                }
            }

            return(null);
        }