예제 #1
0
        public JWTAuthenticationIdentity AuthenticateUser(string userName, string password)
        {
            //TODO - actually validate the user
            if (userName == "kkilton")
            {
                var identity = new JWTAuthenticationIdentity(userName)
                {
                    FirstName = "Kris",
                    LastName  = "Kilton",
                    UserName  = userName,
                    Roles     = new List <string> {
                        "admin"
                    }
                };
                AuthenticationModule.SetUserIdentity(identity);
                return(identity);
            }

            if (userName == "user")
            {
                var identity = new JWTAuthenticationIdentity(userName)
                {
                    FirstName = "Just",
                    LastName  = "User",
                    UserName  = userName,
                    Roles     = new List <string> {
                        "user"
                    }
                };
                AuthenticationModule.SetUserIdentity(identity);
                return(identity);
            }
            throw new AuthenticationException();
        }