コード例 #1
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;
        }
コード例 #2
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);

        }