Example #1
0
        public LoginModel Login(string login, string password)
        {
            if (login.IsNullOrEmpty() || password.IsNullOrEmpty())
            {
                return(PrepareFailedResult(login));
            }

            var user = _userDAO.GetByName(login);

            if (user == null || !user.Password.Equals(password))
            {
                return(PrepareFailedResult(login));
            }

            var sessionId = _sessionProvider.AddSession(user.Id);

            return(new LoginModel
            {
                Result = true,
                Value = sessionId
            });
        }