public ActionResult Register(RegisterArgs arg) { var app = Facade.Caches.OAuthAppCache.Instance.Find(it => string.Equals(Package.MerchantNo, it.APP_CODE, StringComparison.OrdinalIgnoreCase)); if (app == null) { return(FailResult("商户不存在", (int)ApiStatusCode.DATA_NOT_FOUND)); } //先注册,再登录发放TOKEN RegisterProvider provider = new RegisterProvider(Package.UserCode, arg.Password, arg.SmsCode, arg.RefereeCode); if (!provider.Register()) { return(FailResult(provider.PromptInfo.CustomMessage, (int)provider.PromptInfo.ResultType)); } object data = null; LoginProvider loginProvider = new LoginProvider(Package.UserCode, arg.Password); if (loginProvider.Login(Package.ClientSource, Package.ClientSystem, Package.Device_Id, Request.UserHostAddress, Session.SessionID, Package.ClientVersion, app.APP_ID)) { data = new { Token = loginProvider.Token }; } return(SuccessResult(data)); }
public ResponseResult <UserRegisterResponseDTO> UserRegister(UserRegisterRequestDTO request) { UserRegisterResponseDTO response = new UserRegisterResponseDTO(); var app = OAuthAppCache.Get(request.Appid); if (app == null) { return(Fail <UserRegisterResponseDTO>("无效的应用ID", "0400")); } //先注册,再登录发放TOKEN RegisterProvider provider = new RegisterProvider(request.UserCode, request.Password, request.SmsCode, request.RefereeCode); if (!provider.Register()) { return(Fail <UserRegisterResponseDTO>(provider.PromptInfo.CustomMessage)); } LoginProvider loginProvider = new LoginProvider(request.UserCode, request.Password, "basic"); if (loginProvider.Login(request.Client.Type, request.Client.System, request.Client.DeviceId, request.Client.IP, request.Client.SessionId, request.Client.Version, app.Id)) { response.RegisterResult = true; response.Expires = loginProvider.OAuthUser.Expire_In; response.Openid = loginProvider.OAuthUser.Open_Id; response.RefreshExpires = loginProvider.OAuthUser.Refresh_Expire_In; response.RefreshToken = loginProvider.OAuthUser.Refresh_Token; response.Token = loginProvider.OAuthUser.Token; response.UserCode = loginProvider.User.UserCode; } if (!response.RegisterResult) { Log.Info(string.Concat("注册成功,登录失败!", Environment.NewLine, loginProvider.PromptInfo.MessageStack)); } return(Success(response)); }
public JsonResult Register(string sms_code, string mobileno, string loginpwd, string referee_code, string validate_code) { var registerFacade = new RegisterProvider(mobileno, loginpwd, sms_code, referee_code); if (!registerFacade.Register()) { return(FailResult(registerFacade.PromptInfo.CustomMessage, 400)); } return(SuccessResult()); }
public override Task <UserRegisterResponseDTO> UserRegister(UserRegisterRequestDTO request, ServerCallContext context) { return(Task.Run(() => { UserRegisterResponseDTO response = new UserRegisterResponseDTO(); var app = OAuthAppCache.Get(request.Appid); if (app == null) { response.RetCode = "0400"; response.RetMsg = "无效的应用ID"; return response; } //先注册,再登录发放TOKEN RegisterProvider provider = new RegisterProvider(request.UserCode, request.Password, request.SmsCode, request.RefereeCode); if (!provider.Register()) { response.RetCode = xUtils.TransformFailRetCode(provider.PromptInfo.ResultType); response.RetMsg = provider.PromptInfo.CustomMessage; return response; } LoginProvider loginProvider = new LoginProvider(request.UserCode, request.Password, "basic"); if (loginProvider.Login(request.Client.Type, request.Client.System, request.Client.DeviceId, request.Client.Ip, request.Client.SessionId, request.Client.Version, app.Id)) { response.Data = new UserRegisterResponseDTO.Types.Result { Expires = loginProvider.OAuthUser.Expire_In, Openid = loginProvider.OAuthUser.Open_Id, RefreshExpires = loginProvider.OAuthUser.Refresh_Expire_In, RefreshToken = loginProvider.OAuthUser.Refresh_Token, Token = loginProvider.OAuthUser.Token, UserCode = loginProvider.User.UserCode }; } if (response.Data == null) { Log.Info(string.Concat("注册成功,登录失败!", Environment.NewLine, loginProvider.PromptInfo.MessageStack)); } response.RetCode = "0000"; response.RetMsg = "ok"; return response; })); }