Exemplo n.º 1
0
        public AuthorizationResultView Authorize(LoginUserCommand loginUserCommand)
        {
            var user = _identityQueryRepository.QueryAuthorizedUser(loginUserCommand.Login, loginUserCommand.Password).FirstOrDefault();

            var invalidCredentialsMessage = "Invalid user credentials";

            if (user == null)
            {
                throw new ValidationException(invalidCredentialsMessage);
            }

            var redirectUrl = GetRedirectUrl(user.Department);
            var secureToken = RsaHelper.CreateSecureToken(user, ConfigurationManager.AppSettings["publicKeyPath"]);

            return(new AuthorizationResultView()
            {
                AuthorizedUser = user,
                RedirectUrl = redirectUrl,
                Token = secureToken
            });
        }