예제 #1
0
        public string Login(string email, string password)
        {
            LoginUser loginUser = null;

            try
            {
                loginUser = _userOperations.GetLoginUser(email.ToLower());
            }
            catch (NotFoundException)
            {
                throw new AuthenticationException();
            }

            var rehash = Crypto.CalcualteHash(password, loginUser.Salt);

            if (rehash != loginUser.PasswordHash)
            {
                throw new AuthenticationException();
            }

            var userId = loginUser.UserId;

            var user = _userOperations.Get(userId);

            if (!user.Activated)
            {
                throw new ActivationRequiredException();
            }

            _authenticationContext.SetContextUser(userId);

            EnsureEnvironment();

            return(userId);
        }
예제 #2
0
        public IActionResult GetUser([FromRoute] int id)
        {
            var result = _userOperations.Get(id);

            return(Ok(result));
        }