コード例 #1
0
ファイル: LoginController.cs プロジェクト: jcambert/eerp
        // [ValidateAntiForgeryToken]

        /* public async Task<ActionResult<LoginResult>> Index([FromQuery] string licenceOrName,[FromQuery] string prenom =null)
         * {
         *   licenceOrName =  licenceOrName?.ToUpper();
         *   prenom = prenom.TitleCase();
         *
         *   var token = await _authRequest.Login(Request.BaseUrl(), licenceOrName??"",prenom);
         *   if (token.IsError)
         *       return Unauthorized();
         *
         *   int licence;
         *   PingUser user;
         *   if (int.TryParse(licenceOrName, out licence))
         *       user = await _repo.FindByLicenceAsync(licenceOrName);
         *   else
         *       user = await _repo.FindByNameAsync(licenceOrName, prenom);
         *   return new LoginResult() { Jwt = token.AccessToken, User = user ?? default(PingUser) };
         *
         *
         * }*/
        public async Task <ActionResult <LoginResult> > Index([FromForm] LoginModel model)
        {
            model.licenceOrName = model.licenceOrName?.ToUpper();
            model.prenom        = model.prenom.TitleCase();

            var token = await _authRequest.Login(Request.BaseUrl(), model.licenceOrName ?? "", model.prenom);

            if (token.IsError)
            {
                return(Unauthorized());
            }

            int      licence;
            PingUser user;

            if (int.TryParse(model.licenceOrName, out licence))
            {
                user = await _repo.FindByLicenceAsync(model.licenceOrName);
            }
            else
            {
                user = await _repo.FindByNameAsync(model.licenceOrName, model.prenom);
            }
            return(new LoginResult()
            {
                Jwt = token.AccessToken, User = user ?? default(PingUser)
            });
        }
コード例 #2
0
        public string Login(string mobile, string password)
        {
            string      bllRsponse  = string.Empty;
            AuthRequest auth        = new AuthRequest();
            UserRequest userRequest = new UserRequest();

            bllRsponse = auth.Login(mobile, password);
            //bllRsponse = auth.Login("13012345676", "654321");

            // 将接口返回的信息记录在服务端Sesson
            LoginResponse bllRsponseModel = new LoginResponse();

            bllRsponseModel = JsonHelper.DeserializeJsonToObject <LoginResponse>(bllRsponse);

            if (bllRsponseModel.code == 0)
            {
                Session["Phone"] = mobile;
                Session["token"] = bllRsponseModel.data.token;
                Session["role"]  = bllRsponseModel.data.role;

                UserProfileResponse userProfileResponse = userRequest.profile(bllRsponseModel.data.token, "");
                Session["username"]              = userProfileResponse.data.username;
                Session["hospitalid"]            = userProfileResponse.data.hospitalid;
                Session["CurrentUserID"]         = userProfileResponse.data.id;
                Session["CurrentUserHospitalID"] = userProfileResponse.data.hospitalid;
                Session["password"]              = password;
            }

            ////返回接口对象
            return(bllRsponse);
        }
コード例 #3
0
            protected internal async override Task init()
            {
                var response = await Session.CallAsync(AuthRequest.Login(Parameters.Company, Parameters.Username, Parameters.Password), () => Cookies);

                var accountCookie = Session.Cache.Get("HrbcAccount") as string;

                Session.Logger.LogDebug($"AuthSession init session: {response.Session} HRBCACCOUNT={accountCookie}");
                this.Parameters = (response.IsSuccess)
                    ? PrivateAuthentication.WithSession(response.Session, accountCookie, Parameters)
                    : PrivateAuthentication.NoCredentials;
            }
コード例 #4
0
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            AuthRequest   auth      = new AuthRequest();
            LoginResponse respModel = new LoginResponse();

            string strResponse = auth.Login(model.Phone, "654321");

            respModel = JsonHelper.DeserializeJsonToObject <LoginResponse>(strResponse);
            if (respModel.code == 0)
            {
                Session["Phone"] = model.Phone;
                Session["token"] = respModel.data.token;
                Session["role"]  = respModel.data.role;
                return(RedirectToAction("ProjectList", "Project"));
            }
            ModelState.AddModelError("", respModel.message);
            return(View(model));
        }
コード例 #5
0
ファイル: PrivateSession.cs プロジェクト: tranxuannam/bk_data
            protected internal async override Task init()
            {
                var response = await Session.CallAsync(AuthRequest.Login(Parameters.Company, Parameters.Username, Parameters.Password), () => Cookies);

                this.Parameters = (response.IsSuccess) ? PrivateAuthentication.WithSession(response.Session, Parameters) : PrivateAuthentication.NoCredentials;
            }