Beispiel #1
0
        /// <summary>
        /// Receive an Access and Refresh Token
        /// </summary>
        /// <exception cref="LeapPlay.Api.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="loginRequest">Login Request Dto (optional)</param>
        /// <returns>Task of ApiResponse (LoginResponse)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <LoginResponse> > LoginAsyncWithHttpInfo(RequestLoginModel loginRequest = null)
        {
            var    localVarPath         = "./api/v1/auth/login";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json-patch+json",
                "application/json",
                "text/json",
                "application/_*+json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (loginRequest != null && loginRequest.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(loginRequest); // http body (model) parameter
            }
            else
            {
                localVarPostBody = loginRequest; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("Login", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <LoginResponse>(localVarStatusCode,
                                                   localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()),
                                                   (LoginResponse)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(LoginResponse))));
        }
Beispiel #2
0
 public ResponseTokenModel Login(RequestLoginModel request)
 {
     try
     {
         string            result        = HttpUtils.PostRequest(AppConfigMoel.URL + ConstantsValue.HTTP_LOGIN_URI, JsonConvert.SerializeObject(request));
         BaseResponseModel responseModel = JsonConvert.DeserializeObject <BaseResponseModel>(result);
         if (responseModel != null)
         {
             if (responseModel.code.Equals("200"))
             {
                 ResponseTokenModel response = JsonConvert.DeserializeObject <ResponseTokenModel>(responseModel.data.ToString());
                 return(response);
             }
             else
             {
                 return(null);
             }
         }
         return(null);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #3
0
    void OnClick()
    {
        //为快速登录添加回调事件
        QuickBtn.onClick.AddListener(delegate() {
            //向服务器发送请求快速注册
            ExtendHandler.SendMessage(TypeProtocol.LOGIN, LoginProtocol.QUICKREG_CREQ, null);
            //this.Write(TypeProtocol.LOGIN, LoginProtocol.QUICKREG_CREQ, null);
            //GameApp.Instance.NetMessageUtilScript.NetIO.write(TypeProtocol.LOGIN, LoginProtocol.QUICKREG_CREQ, null);
            Debug.Log("请求快速注册登录");
            GameApp.Instance.CommonHintDlgScript.OpenHint("请求快速注册登录");
        });
        //为账号登录添加回调事件
        AccountButton.onClick.AddListener(delegate() {
            string user = UsernameIF.text;
            if (user.Length < 6)
            {
                return;
            }
            //创建一个账号登录对象
            RequestLoginModel rlm = new RequestLoginModel();
            rlm.Ditch             = 0;
            rlm.UserName          = user;
            rlm.Password          = "******";
            this.Write(TypeProtocol.LOGIN, LoginProtocol.ENTER_CREQ, rlm);
            //GameApp.Instance.NetMessageUtilScript.NetIO.write(TypeProtocol.LOGIN, LoginProtocol.ENTER_CREQ, rlm);
            Debug.Log("请求账号登录");
        });
        //为微信登录添加回调事件
        int TouchCount = 0;

        WeChatBtn.onClick.AddListener(() => {
            FNSdk.Instance.WeChatLogin(TouchCount.ToString());
            TouchCount++;
        });
    }
Beispiel #4
0
        public async Task <IActionResult> LoginAsync([FromBody] RequestLoginModel login)
        {
            //if (ModelState.IsValid)
            //{

            //}
            //await _identityServices.CreateRoles();
            var appUser = await _identityServices.GetUserByUserNameAsync(login.Username);

            if (appUser == null)
            {
                return(Unauthorized("Invalid username"));
            }
            var result = await _identityServices.SignInAsync(appUser, login);

            if (!result.Succeeded)
            {
                return(Unauthorized("Invalid password"));
            }
            var tokenString = await _identityServices.GenerateJWTTokenAsync(appUser);

            var listRole = _identityServices.GetRole(appUser);
            var response = new TokenResponseLoginModel()
            {
                UserId      = appUser.Id,
                Username    = appUser.UserName,
                AccessToken = tokenString,
                Role        = listRole == null ? "" : listRole.Result.FirstOrDefault()
            };

            return(Ok(response));
        }
Beispiel #5
0
        /// <summary>
        /// 用户消息到达
        /// </summary>
        /// <param name="token"></param>
        /// <param name="message"></param>
        public void MessageReceive(UserToken token, SocketModel message)
        {
            //处理客户端的请求
            switch (message.command)
            {
            //处理客户端的登录请求
            case GameProtocol.LoginProtocol.ENTER_CREQ:
                DebugUtil.Instance.LogToTime("用户请求登录消息到达");
                //对三级消息体的转换
                RequestLoginModel rlm = message.GetMessage <RequestLoginModel>();
                //获取登录的结果
                int result = BizFactory.login.Login(token, rlm);
                //完成了一次对客户端的消息返回
                token.write(TypeProtocol.LOGIN, LoginProtocol.ENTER_SRES, result);
                break;

            //处理客户端的快速注册请求
            case GameProtocol.LoginProtocol.QUICKREG_CREQ:
                DebugUtil.Instance.LogToTime("用户请求快速注册消息到达");
                ResponseRegisterModel rrmodel = BizFactory.login.Reg(token);
                //完成了一次对客户端请求注册的消息返回
                token.write(TypeProtocol.LOGIN, LoginProtocol.QUICKREG_SRES, rrmodel);
                break;
            }
        }
Beispiel #6
0
        public async Task <SignInResult> SignInAsync(AppUser appUser, RequestLoginModel model)
        {
            var result = await _signInManager.CheckPasswordSignInAsync(appUser,
                                                                       password : model.Password, false);

            return(result);
        }
Beispiel #7
0
        public async Task <IActionResult> LoginUserAsync(RequestLoginModel request)
        {
            var response = await _userService.LoginAsync(request);

            if (response.Errors.Any())
            {
                return(BadRequest(response.Errors));
            }
            return(Ok(response.Data));
        }
Beispiel #8
0
        public async Task <BaseResponse <User> > LoginAsync(RequestLoginModel request)
        {
            var response = new BaseResponse <User>();
            var document = await _userRepository.LoginAsync(request);

            if (document != null)
            {
                response.Data = document;
                return(response);
            }
            response.Errors.Add($"Kullanıcı adı veya şifre yanlış!");
            return(response);
        }
Beispiel #9
0
 public static ResultJson <LoginModel> Login(string username, string password)
 {
     try
     {
         string                  url = UrlModel.ip + UrlModel.login;
         RequestLoginModel       requestLoginModel = new RequestLoginModel(username, password);
         string                  result            = HttpUrlConfig.PostBody(url, requestLoginModel);
         ResultJson <LoginModel> retStu            = JsonConvert.DeserializeObject <ResultJson <LoginModel> >(result);
         Logger.Default.Info(result);
         return(retStu);
     }
     catch (Exception ex)
     {
         Logger.Default.Error(ex.Message);
         return(null);
     }
 }
        ///// <summary>
        ///// 自动登录
        ///// </summary>
        //public bool AutomaticLogon { get { return automaticLogon; } set { this.SetProperty(ref this.automaticLogon,value);} }
        ///// <summary>
        ///// 是否记住密码
        ///// </summary>
        //public bool RememberPwd { get { return rememberPwd; } set { this.SetProperty(ref this.rememberPwd, value); } }

        #endregion

        #region 工作方法
        /// <summary>
        /// 用于验证登陆信息
        /// </summary>
        /// <param name="userID"></param>
        /// <returns>
        /// 返回值代表
        /// -6:密码不正确  -5:用户名不正确
        /// -4:密码含有特殊字符 -3:密码不能为空
        /// -2:用户名不能为空
        /// -1:数据库未连接 0:登陆失败
        ///  1:登陆成功  2:
        ///
        /// </returns>
        public int Verification(ref int userID)
        {
            int flag = 0;

            try
            {
                if (string.IsNullOrEmpty(this.userName))
                {
                    flag = -2;
                    return(flag);
                }
                if (string.IsNullOrEmpty(this.userPassword))
                {
                    flag = -3;
                    return(flag);
                }
                else
                {
                    RequestLoginModel request = new RequestLoginModel();
                    request.account  = this.userName;
                    request.password = this.userPassword;

                    ResponseTokenModel response = new ApiImpl().Login(request);
                    if (response != null)
                    {
                        AppConfigMoel.token = response.token;
                        flag = 1;
                    }
                    else
                    {
                        flag = -6;
                    }
                    System.Threading.Thread.Sleep(1500);
                }
                //flag = 1;
                //System.Threading.Thread.Sleep(1500);
                //Console.WriteLine(this.userName + this.userPassword);
            }
            catch (Exception)
            {
                flag = -1;
                //出现错误无视
            }
            return(flag);
        }
Beispiel #11
0
        public async Task <ApiDataResponse <AuthSuccesfullModel> > Login([FromBody] RequestLoginModel model)
        {
            //modelState
            var person = PersonDtoToRequestLoginMapper.Instance.MapBack(model);
            var result = await authService.LoginPerson(person);

            if (result.Success)
            {
                return(new ApiDataResponse <AuthSuccesfullModel>(new AuthSuccesfullModel
                {
                    Token = result.Token,
                    RefreshToken = result.RefreshToken
                }));
            }
            else
            {
                var apiErrorResult = AuthResultToApiErrorResponceMapper.Instance.Map(result);
                return(new ApiDataResponse <AuthSuccesfullModel>(200, apiErrorResult));
            }
        }
Beispiel #12
0
 void OnClick()
 {
     mQuickBtn.onClick.AddListener(() =>
     {
         Debug.Log("请求快速登录");
         this.Write(TypeProtocol.Login, LoginProtocol.QuickReg_CReq, null);
     });
     mLoginBtn.onClick.AddListener(() =>
     {
         string user = UsernameIF.text;
         if (user.Length < 6)
         {
             return;
         }
         RequestLoginModel rlm = new RequestLoginModel();
         rlm.UserName          = user;
         rlm.password          = "******";
         Debug.Log("请求帐号登录");
         this.Write(TypeProtocol.Login, LoginProtocol.QuickReg_SRes, rlm);
     });
 }
Beispiel #13
0
        /// <summary>
        /// 用户消息到达
        /// </summary>
        /// <param name="token"></param>
        /// <param name="message"></param>
        public void MessageReceive(UserToken token, SocketModel message)
        {
            //处理客户端请求
            switch (message.command)
            {
            //请求登录
            case GameProtocol.LoginProtocol.Login_CReq:
                DebugUtil.Instance.Log2Time("用户请求登录消息到达");
                //对三级消息体的转换
                RequestLoginModel rlm = message.GetMessage <RequestLoginModel>();
                int result            = BizProxy.Login.LoginIn(token, rlm);
                token.write(TypeProtocol.Login, LoginProtocol.Login_SRes, result);
                break;

            //处理客户端注册请求
            case GameProtocol.LoginProtocol.QuickReg_CReq:
                DebugUtil.Instance.Log2Time("用户请求快速注册登录消息到达");
                ResponseRegisterModel rrm = BizProxy.Login.Reg(token);
                token.write(TypeProtocol.Login, LoginProtocol.QuickReg_SRes, rrm);
                break;;
            }
        }
Beispiel #14
0
 /// <summary>
 /// 登入
 /// 返回登录结果
 /// 0登录成功
 /// -1请求错误
 /// -2请求不合法
 /// -3没有此帐号
 /// -4密码错误
 /// -5帐号已登录
 /// </summary>
 /// <param name="token"></param>
 /// <param name="model"></param>
 /// <returns></returns>
 public int LoginIn(UserToken token, RequestLoginModel model)
 {
     //判断请求是否正确
     if (model == null || string.IsNullOrEmpty(model.UserName) || string.IsNullOrEmpty(model.password))
     {
         DebugUtil.Instance.Log2Time("token =" + token.conn.RemoteEndPoint + "请求登录失败,请求错误", logType.Warring);
         return(-1);
     }
     //判断帐号密码是否合法
     if (model.UserName.Length < 6 || (model.password.Length < 6 && model.Ditch == 0))
     {
         DebugUtil.Instance.Log2Time("token =" + token.conn.RemoteEndPoint + "请求登录失败,帐号密码不合法", logType.Warring);
         return(-2);
     }
     //判断是否含有此账号
     if (!CacheProxy.User.IsHasAccount(model.UserName))
     {
         DebugUtil.Instance.Log2Time("token =" + token.conn.RemoteEndPoint + "请求登录失败,没有此账号", logType.Warring);
         return(-3);
     }
     //密码是否正确
     if (model.Ditch == 0 && !CacheProxy.User.IsMatch(model.UserName, model.password))
     {
         DebugUtil.Instance.Log2Time("token =" + token.conn.RemoteEndPoint + "请求登录失败,帐号密码不匹配", logType.Warring);
         return(-4);
     }
     //帐号是否正在登录中
     if (!CacheProxy.User.IsOnline(token))
     {
         DebugUtil.Instance.Log2Time("token =" + token.conn.RemoteEndPoint + "请求登录失败,帐号在线", logType.Warring);
         return(-5);
     }
     //满足条件,登录
     DebugUtil.Instance.Log2Time("username = "******"请求登录验证成功");
     CacheProxy.User.GetOnLine(token, model.UserName);
     return(0);
 }
Beispiel #15
0
 /// <summary>
 /// 返回登录结果
 /// res:int Status
 /// 0表示登录成功
 /// -1请求错误
 /// -2账号密码不合法
 /// -3表示没有此账号
 /// -4表示密码错误
 /// -5表示账号已登录
 /// </summary>
 public int Login(UserToken token, RequestLoginModel model)
 {
     //判定请求是否正确
     if (model == null || string.IsNullOrEmpty(model.Username) || string.IsNullOrEmpty(model.Password))
     {
         DebugUtil.Instance.LogToTime("token = " + token.conn.RemoteEndPoint + "请求登录失败,请求错误", LogType.WARRING);
         return(-1);
     }
     //判定账号密码是否合法
     if (model.Username.Length < 6 || (model.Ditch == 0 && model.Password.Length < 6))
     {
         DebugUtil.Instance.LogToTime("token = " + token.conn.RemoteEndPoint + "请求登录失败,账号密码不合法", LogType.WARRING);
         return(-2);
     }
     //判断是否含有此账号
     if (!CacheFactory.user.IshasAccount(model.Username))
     {
         DebugUtil.Instance.LogToTime("username = "******"请求登录失败,没有此账号", LogType.WARRING);
         return(-3);
     }
     //是否密码正确
     if (model.Ditch == 0 && !CacheFactory.user.IsPassword(model.Username, model.Password))
     {
         DebugUtil.Instance.LogToTime("username = "******"请求登录失败,账号密码不匹配", LogType.WARRING);
         return(-4);
     }
     //账号是否正在登陆中
     if (CacheFactory.user.IsOnline(token))
     {
         DebugUtil.Instance.LogToTime("username = "******"请求登录失败,账号已在线", LogType.WARRING);
         return(-5);
     }
     DebugUtil.Instance.LogToTime("username = "******"请求登录验证成功");
     //全部条件满足,进行登录
     CacheFactory.user.Online(token, model.Username);
     return(0);
 }
Beispiel #16
0
        //로그인 Command
        public async void Login()
        {
            try
            {
                if (IsMaintenance)
                {
                    return;
                }

                if (TempUserName != UserName)
                {
                    TempUserName     = UserName;
                    LoginSubmitCount = 0;
                    LoginSubmitCheck = true;
                }

                if (LoginSubmitCount == 5 && LoginSubmitCheck)
                {
                    using (RequestLoginFailModel req = new RequestLoginFailModel())
                    {
                        req.userEmail = UserName;

                        using (ResponseLoginFailModel res = await WebApiLib.AsyncCall <ResponseLoginFailModel, RequestLoginFailModel>(req))
                        {
                            LoginSubmitCount = 0;
                            LoginSubmitCheck = false;
                            Alert alert = new Alert(Localization.Resource.Login_4, 400);
                            alert.ShowDialog();
                            return;
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(UserName))
                {
                    Alert alert = new Alert(Localization.Resource.Login_5);
                    alert.ShowDialog();
                    return;
                }
                if (string.IsNullOrWhiteSpace(Password))
                {
                    Alert alert = new Alert(Localization.Resource.Login_6);
                    alert.ShowDialog();
                    return;
                }

                #region ID 저장 Check

                if (IsCheck)
                {
                    ini.SetCheckID(UserName.Trim(), "Login", "ID");
                }
                else
                {
                    ini.SetCheckID(string.Empty, "Login", "ID");
                }

                ini.SetCheckID(SelectedLang.Lv, "Language", "Country");

                #endregion

                IsBusy = true;

                Dictionary <string, string> dict = null;

                using (RequestPublicKeyModel req = new RequestPublicKeyModel())
                {
                    using (ResponsePublicKeyModel res = WebApiLib.SyncCall <ResponsePublicKeyModel, RequestPublicKeyModel>(req))
                    {
                        //dict = EncodingLib.AesEncrypt(Password.Trim(), res.data.pubKeyModule, res.data.pubKeyExponent);
                        dict = EncodingLib.AesEncryptKey(res.data.pubKeyModule, res.data.pubKeyExponent);
                    }
                }

                if (dict.Count == 2)
                {
                    using (RequestLoginModel req = new RequestLoginModel())
                    {
                        req.userEmail = UserName.Trim();
                        req.userPwd   = EncodingLib.AesEncrypt(Password.Trim(), dict["gid"]);
                        req.clientPe  = dict["acekey"];
                        req.langCd    = SelectedLang.Lv.ToString().Split('-')[0];
                        req.regIp     = CommonLib.Client_IP;

                        using (ResponseLoginModel res = await WebApiLib.AsyncCall <ResponseLoginModel, RequestLoginModel>(req))
                        {
                            if (res.data.loginYn.Equals("Y"))
                            {
                                if (res.data.isIpFirst.Equals("Y"))
                                {
                                    Views.NoticePopup note = new Views.NoticePopup(NoticePopup.KindNotice.HTS_IP_CHECK_1);
                                    note.Title = Localization.Resource.NoticePopup_3;
                                    if (note.ShowDialog() == true)
                                    {
                                        note       = new Views.NoticePopup(NoticePopup.KindNotice.HTS_IP_CHECK_2);
                                        note.Title = Localization.Resource.NoticePopup_3;
                                        note.ShowDialog();

                                        IsLoginView = Visibility.Collapsed;
                                        Messenger.Default.Send(res.data);
                                    }
                                    else
                                    {
                                        //IP삭제
                                        using (RequestIpRegModel req2 = new RequestIpRegModel())
                                        {
                                            req2.userEmail = UserName.Trim();
                                            req2.ip        = res.data.regIp;
                                            req2.limtHr    = 0;
                                            using (ResponseIpRegModel res2 = await WebApiLib.AsyncCall <ResponseIpRegModel, RequestIpRegModel>(req2))
                                            {
                                                //IP삭제 완료
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    IsLoginView = Visibility.Collapsed;
                                    Messenger.Default.Send(res.data);
                                }
                            }
                            else
                            {
                                IsBusy = false;
                                if (res.resultMsg != null)
                                {
                                    if (res.data.lockYn == "Y")
                                    {
                                        Alert alert = new Alert("[" + Localization.Resource.Login_20 + "]" + "\n" + Localization.Resource.Login_18 + "\n" + Localization.Resource.Login_19, 460, 180);
                                        if (alert.ShowDialog() == true)
                                        {
                                            using (RequestPwdChangeModel req2 = new RequestPwdChangeModel())
                                            {
                                                req2.userEmail = UserName.Trim();

                                                using (ResponsePwdChagneModel res2 = WebApiLib.SyncCall <ResponsePwdChagneModel, RequestPwdChangeModel>(req2))
                                                {
                                                    if (res2.resultStrCode == "000")
                                                    {
                                                        alert = new Alert(Localization.Resource.Login_23, 330);
                                                        alert.ShowDialog();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.notExistPassword)))
                                        {
                                            LoginSubmitCount++;
                                            if (LoginSubmitCount == 5)
                                            {
                                                LoginSubmitCheck = true;
                                            }
                                            Alert alert = new Alert(string.Format(Localization.Resource.Login_24, LoginSubmitCount) + "\n" + Localization.Resource.Login_25, 300);
                                            alert.ShowDialog();
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.blockID)))
                                        {
                                            LoginSubmitCount = 0;
                                            LoginSubmitCheck = false;

                                            Alert alert = new Alert(Localization.Resource.Login_4, 400);
                                            alert.ShowDialog();
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.userEmailFail)))
                                        {
                                            Alert alert = new Alert(Localization.Resource.Login_11, 300);
                                            alert.ShowDialog();
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.userPasswordFail)))
                                        {
                                            Alert alert = new Alert(Localization.Resource.Login_12, 300);
                                            alert.ShowDialog();
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.notExistEmail)))
                                        {
                                            Alert alert = new Alert(Localization.Resource.Login_13, 300);
                                            alert.ShowDialog();
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.NotRegIP)))
                                        {
                                            NoticePopup note = new NoticePopup(NoticePopup.KindNotice.HTS_IP_NOT_CHECK_1);
                                            note.Title = Localization.Resource.NoticePopup_4;
                                            NoticePopupViewModel.UserName = UserName.Trim();
                                            if (note.ShowDialog() == true)
                                            {
                                                IpRegisterViewModel.regIp     = res.data.regIp;
                                                IpRegisterViewModel.userEmail = UserName.Trim();
                                                IpRegister ip = new IpRegister();
                                                ip.ShowDialog();
                                            }
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.NotUseID)))
                                        {
                                            Alert alert = new Alert(Localization.Resource.Login_16, 300);
                                            alert.ShowDialog();
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.loginFailCode)))
                                        {
                                            Alert alert = new Alert(Localization.Resource.Login_17, 350);
                                            alert.ShowDialog();
                                        }
                                        else if (res.data.failCd.Equals(StringEnum.GetStringValue(EnumLib.LoginFailCode.ReSettingPW)))
                                        {
                                            Alert alert = new Alert(Localization.Resource.Login_21, 300, 140, Localization.Resource.Login_22);
                                            if (alert.ShowDialog() == true)
                                            {
                                                using (RequestPwdChangeModel req2 = new RequestPwdChangeModel())
                                                {
                                                    req2.userEmail = UserName.Trim();

                                                    using (ResponsePwdChagneModel res2 = WebApiLib.SyncCall <ResponsePwdChagneModel, RequestPwdChangeModel>(req2))
                                                    {
                                                        if (res2.resultStrCode == "000")
                                                        {
                                                            alert = new Alert(Localization.Resource.Login_23, 330);
                                                            alert.ShowDialog();
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Alert alert = new Alert(Localization.Resource.Login_17, 350);
                                            alert.ShowDialog();
                                        }
                                    }
                                }
                                else
                                {
                                    Alert alert = new Alert(Localization.Resource.Login_7, 320);
                                    alert.ShowDialog();
                                }
                            }
                        }
                    }
                }
                else
                {
                    Alert alert = new Alert(Localization.Resource.Login_8, Alert.ButtonType.Ok);
                    alert.ShowDialog();
                }

                IsBusy = false;
            }
            catch (Exception ex)
            {
                SysLog.Error("Message[{0}], StackTrace[{1}]", ex.Message, ex.StackTrace);
                IsBusy = false;

                Alert alert = new Alert(Localization.Resource.Login_9, Alert.ButtonType.Ok);
                alert.ShowDialog();
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #17
0
        /// <summary>
        /// Receive an Access and Refresh Token
        /// </summary>
        /// <exception cref="LeapPlay.Api.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="loginRequest">Login Request Dto (optional)</param>
        /// <returns>LoginResponse</returns>
        public LoginResponse Login(RequestLoginModel loginRequest = null)
        {
            ApiResponse <LoginResponse> localVarResponse = LoginWithHttpInfo(loginRequest);

            return(localVarResponse.Data);
        }
        public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
        {
            try
            {
                RequestLoginModel request = new RequestLoginModel
                {
                    Email    = context.UserName,
                    Password = context.Password
                };

                ResponseAuthorizationModel response =
                    await _httpClientHelper.PostAsync <RequestLoginModel, ResponseAuthorizationModel>(
                        $"api/v1/Users/authorization",
                        request);

                if (response != null)
                {
                    var claims = new List <Claim>
                    {
                        new Claim(UserId, response.UserId.ToString()),
                        new Claim(JwtClaimTypes.Email, response.Email),
                        new Claim(JwtClaimTypes.EmailVerified, "true", ClaimValueTypes.Boolean)
                    };

                    foreach (var item in response.Claims)
                    {
                        claims.Add(new Claim(item.Type, item.Value));
                    }

                    var result = new Dictionary <string, object>
                    {
                        { "Username", response.UserName },
                        { "Email", response.Email }
                    };

                    context.Result = new GrantValidationResult(response.UserId.ToString(), AuthorizationMethod, claims, customResponse: result);

                    await Task.FromResult(context.Result);
                }
                else
                {
                    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidRequest, ErrorCode.NotFound.ToString());
                    await Task.FromResult(context.Result);
                }
            }
            catch (HttpResponseException e)
            {
                switch (e.StatusCode)
                {
                case HttpStatusCode.BadRequest:
                    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidRequest, ErrorCode.Lock.ToString());
                    break;

                default:
                    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidRequest, e.StatusCode.ToString());
                    break;
                }
            }
            finally
            {
                await Task.FromResult(context.Result);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Receive an Access and Refresh Token
        /// </summary>
        /// <exception cref="LeapPlay.Api.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="loginRequest">Login Request Dto (optional)</param>
        /// <returns>Task of LoginResponse</returns>
        public async System.Threading.Tasks.Task <LoginResponse> LoginAsync(RequestLoginModel loginRequest = null)
        {
            ApiResponse <LoginResponse> localVarResponse = await LoginAsyncWithHttpInfo(loginRequest);

            return(localVarResponse.Data);
        }
 public async Task <User> LoginAsync(RequestLoginModel request)
 {
     return(await _mongoCollection.Find(aa => aa.UserName == request.Username && aa.Password == request.Password.MD5Hash() && aa.IsDeleted == false).FirstOrDefaultAsync());
 }