public async Task <AuthRes> AutoLoginCheck() { if (userService == null) { userService = MagicOnionClient.Create <IUserService>(baseNetworkManager.ConnectChannel()); } if (PlayerPrefs.HasKey(PREF_AUTH_USERID) && PlayerPrefs.HasKey(PREF_AUTH_PASSWORD)) { string userId = saveAES.Decrypt(PlayerPrefs.GetString(PREF_AUTH_USERID)); string password = saveAES.Decrypt(PlayerPrefs.GetString(PREF_AUTH_PASSWORD)); accessToken = await userService.LoginCheck(sendAES.Encrypt(userId), sendAES.Encrypt(password), (int)CheckMode.UserId); if (accessToken == "") { return(AuthRes.Failed); } } else { return(AuthRes.NoAccount); } return(AuthRes.Success); }
void Start() { if (!File.Exists(FileName)) { return; } // 読込 string config = File.ReadAllText(FileName); config = AESCryption.Decrypt(config); string[] token = config.Split(','); Access = new AccessTokenResponse { Token = token[0], TokenSecret = token[1], UserId = token[2], ScreenName = token[3] }; // 認証済 Text.text = Ready; Input.placeholder.GetComponent <Text>().text = PlaceholderReady; }
/// <summary> /// 発行した一意のUserIdかEmailで認証 /// </summary> /// <param name="encUserIdOrEmail">encript UserID or Email</param> /// <param name="encPassword">encript Password</param> /// <param name="mode">0:userId/1:email</param> /// <returns>accessToken</returns> public UnaryResult <string> LoginCheck(string encUserIdOrEmail, string encPassword, int mode) { try { string userId = ""; string email = ""; string password = sendAES.Decrypt(encPassword); if (mode == 0) { userId = sendAES.Decrypt(encUserIdOrEmail); Logger.Debug($"{userId}:{password}"); if (userIdDictionary.ContainsKey(userId)) { string checkPassword = saveAES.Decrypt(userIdDictionary[userId]); if (checkPassword.Equals(password)) { string accessToken = GetCsrfToken(); Logger.Debug("accessToken:" + accessToken); return(new UnaryResult <string>(sendAES.Encrypt(accessToken))); } } } else { email = sendAES.Decrypt(encUserIdOrEmail); Logger.Debug($"{email}:{password}"); if (emailDictionary.ContainsKey(email)) { string checkPassword = saveAES.Decrypt(emailDictionary[email]); if (checkPassword.Equals(password)) { string accessToken = GetCsrfToken(); Logger.Debug("accessToken:" + accessToken); return(new UnaryResult <string>(sendAES.Encrypt(accessToken))); } } } } catch (Exception e) { Logger.Debug(e.Message); } return(new UnaryResult <string>("")); }
public async Task <AuthRes> AccountRegister(string userName, string email, string password) { if (userService == null) { userService = MagicOnionClient.Create <IUserService>(baseNetworkManager.ConnectChannel()); } string encUserId = await userService.AccountRegister(sendAES.Encrypt(userName), sendAES.Encrypt(email), sendAES.Encrypt(password)); if (encUserId == "") { return(AuthRes.Failed); } string userId = sendAES.Decrypt(encUserId); //送信とは別のキーで暗号化して保管 PlayerPrefs.SetString(PREF_AUTH_USERID, saveAES.Encrypt(userId)); PlayerPrefs.SetString(PREF_AUTH_PASSWORD, saveAES.Encrypt(password)); return(AuthRes.Success); }