/// <summary> /// 注册用户信息 /// </summary> /// <param name="value">注册的账号信息</param> /// <param name="passWord">密码</param> /// <param name="passCode"> 验证码(手机号注册时需要 </param> /// <param name="type">注册类型</param> /// <returns></returns> public async Task <ResultMo <UserInfoMo> > RegisteUser(string value, string passWord, string passCode, RegLoginType type) { // todo 如果是手机号注册,检查验证码 var checkRes = await CheckIfCanRegiste(type, value); if (!checkRes.IsSuccess()) { return(checkRes.ConvertToResultOnly <UserInfoMo>()); } var userInfo = GetRegisteUserInfo(value, passWord, type); var idRes = await InsContainer <IUserInfoRep> .Instance.Insert(userInfo); if (!idRes.IsSuccess()) { return(idRes.ConvertToResultOnly <UserInfoMo>()); } userInfo.Id = idRes.id; MemberEvents.TriggerUserRegiteEvent(userInfo, MemberShiper.AppAuthorize); return(new ResultMo <UserInfoMo>(userInfo.ConvertToMo())); }
public async Task <IActionResult> Edit(int id, [Bind("MemberEventsId,EventId,MemberId")] MemberEvents memberEvents) { if (id != memberEvents.MemberEventsId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(memberEvents); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MemberEventsExists(memberEvents.MemberEventsId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Events, "EventId", "EventName", memberEvents.EventId); ViewData["MemberId"] = new SelectList(_context.Members, "MemberId", "MemberId", memberEvents.MemberId); return(View(memberEvents)); }
public async Task <ResultMo <UserInfoMo> > LoginUser(string name, string passWord, RegLoginType type) { var rep = InsContainer <IUserInfoRep> .Instance; var userRes = await(type == RegLoginType.Mobile ? rep.Get <UserInfoBigMo>(u => u.mobile == name) : rep.Get <UserInfoBigMo>(u => u.email == name)); if (!userRes.IsSuccess()) { return(userRes.ConvertToResultOnly <UserInfoMo>()); } if (Md5.EncryptHexString(passWord) != userRes.data.pass_word) { return(new ResultMo <UserInfoMo>(ResultTypes.UnAuthorize, "账号密码不正确!")); } MemberEvents.TriggerUserLoginEvent(userRes.data, MemberShiper.AppAuthorize); var checkRes = CheckMemberStatus(userRes.data.status); return(checkRes.IsSuccess() ? new ResultMo <UserInfoMo>(userRes.data.ConvertToMo()) : checkRes.ConvertToResultOnly <UserInfoMo>()); }
/// <summary> /// 注册第三方信息到系统中 /// </summary> /// <param name="plat"></param> /// <param name="code"></param> /// <param name="state"></param> /// <returns></returns> public async Task <UserTokenResp> SocialAuth(SocialPaltforms plat, string code, string state) { var oauthUserRes = await AddOrUpdateOauthUser(plat, code, state); if (!oauthUserRes.IsSuccess()) { return(oauthUserRes.ConvertToResult <UserTokenResp>()); } UserInfoBigMo user; var type = MemberAuthorizeType.User; var oauthUser = oauthUserRes.data; if (oauthUser.user_id > 0) // 已经存在绑定,直接登录成功 { var userRes = await UserInfoRep.Instance.GetById(oauthUser.user_id); if (!userRes.IsSuccess()) { return(userRes.ConvertToResult <UserTokenResp>()); } user = userRes.data; MemberEvents.TriggerUserLoginEvent(user, MemberShiper.AppAuthorize); } else { var regConfig = GetRegConfig(MemberShiper.AppAuthorize); user = oauthUser.ConvertToBigMo(); if (regConfig.OauthRegisteType == OauthRegisteType.JustRegiste) { // 授权后直接注册用户 var idRes = await UserInfoRep.Instance.Add(user); if (!idRes.IsSuccess()) { return(idRes.ConvertToResult <UserTokenResp>()); } user.id = idRes.id; #pragma warning disable 4014 OauthUserRep.Instance.UpdateUserIdByOauthId(oauthUser.id, user.id); #pragma warning restore 4014 MemberEvents.TriggerUserLoginEvent(user, MemberShiper.AppAuthorize); } else { // 授权后通知前端,执行绑定相关操作 user.id = oauthUser.id; user.status = regConfig.OauthRegisteType == OauthRegisteType.Bind ? (int)MemberStatus.WaitOauthBind : (int)MemberStatus.WaitOauthChooseBind; type = MemberAuthorizeType.OauthUserTemp; } } return(GenerateUserToken(user, type)); }
private static UserTokenResp LoginExcute(UserInfoBigMo user) { MemberEvents.TriggerUserLoginEvent(user, MemberShiper.AppAuthorize); var checkRes = CheckMemberStatus(user.status); return(checkRes.IsSuccess() ? BindOauthAndGenerateUserToken(user, MemberAuthorizeType.User) : checkRes.ConvertToResult <UserTokenResp>()); }
public MemberEvents Subscribe(int eventId, string memberId) { // Create a new MemberEvent object and add the memberId string reference object and the id supplied to this method MemberEvents newMemberEvent = new MemberEvents(); newMemberEvent.MemberId = memberId; newMemberEvent.EventId = eventId; return(newMemberEvent); }
public async Task <IActionResult> Create([Bind("MemberEventsId,EventId,MemberId")] MemberEvents memberEvents) { if (ModelState.IsValid) { _context.Add(memberEvents); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EventId"] = new SelectList(_context.Events, "EventId", "EventName", memberEvents.EventId); ViewData["MemberId"] = new SelectList(_context.Members, "MemberId", "MemberId", memberEvents.MemberId); return(View(memberEvents)); }
private static async Task <UserTokenResp> RegExcute(string name, string passWord, RegLoginType type) { var userInfo = GetRegisteUserInfo(name, passWord, type); var idRes = await UserInfoRep.Instance.Add(userInfo); if (!idRes.IsSuccess()) { return(idRes.ConvertToResult <UserTokenResp>()); } userInfo.id = idRes.id; MemberEvents.TriggerUserRegiteEvent(userInfo, MemberShiper.AppAuthorize); return(BindOauthAndGenerateUserToken(userInfo, MemberAuthorizeType.User)); }
/// <summary> /// 注册用户信息 /// </summary> /// <param name="value">注册的账号信息</param> /// <param name="passWord">密码</param> /// <param name="passCode"> 验证码(手机号注册时需要 </param> /// <param name="type">注册类型</param> /// <returns></returns> public async Task <ResultMo <UserInfoMo> > RegisteUser(string value, string passWord, string passCode, RegLoginType type) { var checkRes = await CheckIfCanRegiste(type, value); if (!checkRes.IsSuccess()) { return(checkRes.ConvertToResultOnly <UserInfoMo>()); } // todo 检查验证码 var userInfo = new UserInfoBigMo(); if (type == RegLoginType.Email) { userInfo.email = value; } else { userInfo.mobile = value; } if (type != RegLoginType.MobileCode) { userInfo.pass_word = Md5.HalfEncryptHexString(passWord); } var idRes = await InsContainer <IUserInfoRep> .Instance.Insert(userInfo); if (!idRes.IsSuccess()) { return(idRes.ConvertToResultOnly <UserInfoMo>()); } userInfo.Id = idRes.id; MemberEvents.TriggerUserRegiteEvent(userInfo, MemberShiper.AppAuthorize); return(new ResultMo <UserInfoMo>(userInfo)); }
private void Initialize() { try { context.Entry(memberEvents).State = EntityState.Detached; } catch (Exception) { } events = new Events() { EventId = r.Next(), EventName = "TestEvent", EventDate = DateTime.Now, StartTime = TimeSpan.Zero, EndTime = TimeSpan.Zero, Capacity = 500 }; memberEvents = new MemberEvents() { MemberEventsId = r.Next(), EventId = events.EventId, MemberId = "TestMemberId", Event = events }; }