Пример #1
0
        async Task <bool> tryToRelogin()
        {
            try
            {
                var athlete = repository.GetMyAthlete();
                if (athlete == null || athlete.AthleteID <= 0)
                {
                    return(false);
                }

                if (athlete.HasFacebookId)
                {
                    string facebookAccessToken = facebookService.FacebookAccessToken;
                    if (string.IsNullOrEmpty(facebookAccessToken))
                    {
                        facebookAccessToken = keyChain.Get("facebook");
                    }
                    if (string.IsNullOrEmpty(facebookAccessToken))
                    {
                        return(false);
                    }

                    // build user name and password to login to Byb
                    string loginEmail = LoginHelper.BuildLoginEmailFromFacebookId(athlete.FacebookId);
                    string password   = LoginHelper.BuildLoginPasswordFromFacebookId(athlete.FacebookId);

                    // try logging in
                    updateWaitPageStatus("Connecting with " + Config.WebsiteName);
                    if (!await this.webservice.Login(loginEmail, password, facebookAccessToken))
                    {
                        return(false);
                    }
                }
                else
                {
                    string password = keyChain.Get(athlete.UserName);
                    if (string.IsNullOrEmpty(password))
                    {
                        return(false);
                    }

                    if (!await webservice.Login(athlete.UserName, password, null))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Пример #2
0
 private Score loadScore()
 {
     try
     {
         string json = keyChain.Get(KeyChainName);
         if (string.IsNullOrEmpty(json))
         {
             return(null);
         }
         Score score = Newtonsoft.Json.JsonConvert.DeserializeObject <Score> (json);
         return(score);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Пример #3
0
        public static FVOConfig LoadFromKeyChain(IKeyChain keychain)
        {
            FVOConfig config = null;

            try
            {
                string str = keychain.Get("FVOConfig");
                config = Newtonsoft.Json.JsonConvert.DeserializeObject <FVOConfig>(str);
            }
            catch (Exception)
            {
            }

            if (config == null)
            {
                config = new FVOConfig();
            }

            return(config);
        }