private async Task LoginUser() { var loginModel = new LoginModel { Email = emailInput.Text, Password = passwordInput.Text }; var tokenModel = await this.signInService.SignInUserStandard(loginModel); if (tokenModel != null) { preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token); if (tokenModel.UserHasToSetNickName) { GoToActivity(new Intent(this, typeof(StartActivity))); } else { SetUserNameInAppSettings(tokenModel.UserName); GoToActivity(new Intent(this, typeof(MainActivity))); } } else { AlertsService.ShowLongToast(this, "Podany email lub has³o s¹ b³êdne"); } }
private async Task RegisterUser() { var registerModel = new RegisterModel { Email = emailInput.Text, Password = passwordInput.Text, ConfirmPassword = confirmPasswordInput.Text }; var tokenModel = await this.signInService.RegisterUser(registerModel); if (tokenModel != null) { if (String.IsNullOrEmpty(tokenModel.Token)) { AlertsService.ShowLongToast(this, "Podany email ju¿ istnieje w bazie u¿ytkowników!"); } else { var preferenceHelper = new SharedPreferencesHelper(this); preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token); GoToStartActivity(); } } else { AlertsService.ShowLongToast(this, "Coœ posz³o nie tak na serwerze!"); } }
private async Task RegisterUser() { var registerModel = new RegisterModel { Email = emailInput.Text, Password = passwordInput.Text, ConfirmPassword = confirmPasswordInput.Text }; var tokenModel = await this.signInService.RegisterUser(registerModel); if (tokenModel != null) { var preferenceHelper = new SharedPreferencesHelper(this); preferenceHelper.SetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token); GoToMainActivity(); } else { AlertsService.ShowToast(this, "Coœ posz³o nie tak na serwerze!"); } }
private async Task <bool> SignInUser() { var userIsLogged = false; preferenceHelper = new SharedPreferencesHelper(this); var bearerToken = (string)preferenceHelper.GetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN); if (bearerToken != null) { userIsLogged = await signInService.SignInUserWithBearerToken(GetTokenModel()); } if (!userIsLogged) { if (AccessToken.CurrentAccessToken != null && AccessToken.CurrentAccessToken.Token != null) { var facebookToken = new FacebookTokenViewModel { FacebookToken = AccessToken.CurrentAccessToken.Token }; var tokenModel = await signInService.SignInUserWithFacebookToken(facebookToken); if (tokenModel != null) { preferenceHelper.SetSharedPreference <string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token); if (tokenModel.UserHasToSetNickName) { throw new UserHasToSetNickNameException(); } else { SharedPreferencesHelper.SetUserNameInAppSettings(this, tokenModel.UserName); } userIsLogged = true; } } } return(userIsLogged); }
private async Task<bool> SignInUser() { var userIsLogged = false; var preferenceHelper = new SharedPreferencesHelper(this); var bearerToken = (string)preferenceHelper.GetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN); if (bearerToken != null) { userIsLogged = await signInService.SignInUserWithBearerToken(new TokenModel { Token = bearerToken }); } if (!userIsLogged) { if (AccessToken.CurrentAccessToken != null && AccessToken.CurrentAccessToken.Token != null) { var facebookToken = new FacebookTokenViewModel { FacebookToken = AccessToken.CurrentAccessToken.Token }; var tokenModel = await signInService.SignInUserWithFacebookToken(facebookToken); if (tokenModel != null) { preferenceHelper.SetSharedPreference<string>(SharedPreferencesKeys.BEARER_TOKEN, tokenModel.Token); userIsLogged = true; } } } return userIsLogged; }