Beispiel #1
0
        public LoginResult Authenticate(UserAuthen user)
        {
            if (user == null)
                throw new HttpResponseException(new HttpResponseMessage() { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("Please provide the credentials.") });

            if (IoTUserMrg.IsValidUser(user,false))
            {
                UGToken token = new UGToken(user);
                var status = new LoginResult() { Successeded = true, UGToken = token.Encrypt(), Message = "Successfully signed in." };

                //Get data attach (List<int> storesId) - List store by User
                var lst = new List<int>() { 1 };

                Profile p = new Profile();
                p.Stores = lst;

                string profile = p.SerializeJson();
                //Update profile
                IoTUserMrg.UpdateProfile(user.UserName, profile);

                //status attach data
                status.ProfileJson = profile;
                return status;
            }
            else
            {
                throw new HttpResponseException(new HttpResponseMessage() { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("Invalid user name or password.") });
            }
        }
Beispiel #2
0
 public User GetUser(UGToken token)
 {
     return GetUser(new UserAuthen(token));
 }