private User InitUser(KinveyAuthResponse response, string userType) // TODO move to UserFactory? { CredentialManager credentialManager = new CredentialManager(this.abstractClient.Store); Credential activeUserCredential = credentialManager.CreateAndStoreCredential(response, response.UserId, abstractClient.SSOGroupKey, abstractClient.DeviceID); return(InitUser(activeUserCredential)); }
/// <summary> /// Creates a new Credential object from a Kinvey user login/create request, and saves the it in the Credential Store. /// </summary> /// <returns>The and store credential.</returns> /// <param name="response">Response.</param> /// <param name="userId">User _id.</param> /// <param name="ssoGroupKey">SSO Group Key.</param> public Credential CreateAndStoreCredential(KinveyAuthResponse response, string userId, string ssoGroupKey, string deviceID) { Credential newCredential = Credential.From(response); newCredential.DeviceID = deviceID; if (userId != null && credentialStore != null) { var oldCred = credentialStore.Load(userId, ssoGroupKey); newCredential.MICClientID = oldCred?.MICClientID; credentialStore.Store(userId, ssoGroupKey, newCredential); } return(newCredential); }
internal async Task <User> ExecuteAsync() { if (this.abstractClient.ActiveUser != null && this.type != EnumLoginType.CREDENTIALSTORE) { throw new KinveyException(EnumErrorCategory.ERROR_USER, EnumErrorCode.ERROR_USER_ALREADY_LOGGED_IN, ""); } string userType = ""; if (this.type == EnumLoginType.CREDENTIALSTORE) { return(this.InitUser(credential)); } else { userType = this.type.ToString(); } KinveyAuthResponse response = await this.request.ExecuteAsync(); return(InitUser(response, userType)); }
/// <summary> /// Create a new Credential from a KinveyAuthResponse. /// </summary> /// <param name="response">The response of a Kinvey login/create request.</param> public static Credential From(KinveyAuthResponse response) { return(new Credential(response.UserId, response.AccessToken, response.AuthSocialIdentity, response.AuthToken, response.username, response.Attributes, response.UserMetaData, null, null, null, null)); }