예제 #1
0
        public async static Task<string> Authenticate(string email, string password)
        {
            var faileMessage = "Authentication failed";
            try
            {
                //authenticate user on Appacitive
                var credentials = new UsernamePasswordCredentials(email, password)
                {
                    TimeoutInSeconds = int.MaxValue,
                    MaxAttempts = int.MaxValue
                };

                await Appacitive.Sdk.AppContext.LoginAsync(credentials);

                return null;
            }
            catch { }
            return faileMessage;
        }
예제 #2
0
 public string Login(ref Account account, out string errorMessage)
 {
     string token = string.Empty;
     errorMessage = string.Empty;
     var creds = new UsernamePasswordCredentials(account.UserName, account.Password)
     {
         TimeoutInSeconds = 15*60,
         MaxAttempts = int.MaxValue
     };
     try
     {
         // Authenticate
         var result = creds.AuthenticateAsync().Result;
         if (result != null)
         {
             User loggedInUser = result.LoggedInUser;
             token = result.UserToken;
             var profile = loggedInUser.GetConnectedArticlesAsync(Relations.UserProfile).Result;
             account = loggedInUser.ToModelAccount(profile.SingleOrDefault());
         }
         else
         {
             errorMessage = "Username and password doesnt match!! Retry.";
         }
     }
     catch (Exception ex)
     {
         errorMessage = ex.Message;
     }
     return token;
 }