Beispiel #1
0
        public string Authenticate(User user)
        {
            ICredentialsValidator validator = new CredentialsValidatorImpl();

            if (validator.IsValid(user))
            {
                return(new TokenBuilderImpl().Build(user));
            }
            throw new InvalidCredentialException("Invalid credentials");
        }
Beispiel #2
0
        public string Authenticate(User user)
        {
            ICredentialsValidator validator = new CredentialsValidatorImpl();
            var data = validator.IsValid(user);

            if (data.Id > 0)
            {
                var token = new TokenBuilderImpl().Build(data);
                HttpContext.Current.Response.AddHeader(token, "Token");
                return("Ok");
            }
            else
            {
                return("UnAuthorized Request");
            }
        }