protected virtual async Task RemoveWeChatAppUserAsync(IdentityUser identityUser, WeChatApp miniProgram) { var mpUserMapping = await _weChatAppUserRepository.GetAsync(x => x.WeChatAppId == miniProgram.Id && x.UserId == identityUser.Id); await _weChatAppUserRepository.DeleteAsync(mpUserMapping, true); }
public virtual Task <string> GetOpenLoginProviderAsync(WeChatApp miniProgram) { Check.NotNullOrWhiteSpace(miniProgram.OpenAppIdOrName, nameof(miniProgram.OpenAppIdOrName)); return(Task.FromResult(WeChatOpenLoginProviderPrefix + miniProgram.OpenAppIdOrName)); }
protected virtual async Task UpdateWeChatAppUserAsync(IdentityUser identityUser, WeChatApp miniProgram, string unionId, string openId, string sessionKey) { var mpUserMapping = await _weChatAppUserRepository.FindAsync(x => x.WeChatAppId == miniProgram.Id && x.UserId == identityUser.Id); if (mpUserMapping == null) { mpUserMapping = new WeChatAppUser(GuidGenerator.Create(), CurrentTenant.Id, miniProgram.Id, identityUser.Id, unionId, openId); await _weChatAppUserRepository.InsertAsync(mpUserMapping, true); } else { mpUserMapping.SetOpenId(openId); mpUserMapping.SetUnionId(unionId); mpUserMapping.UpdateSessionKey(sessionKey, Clock); await _weChatAppUserRepository.UpdateAsync(mpUserMapping, true); } }