示例#1
0
        public IActionResult Login(LoginIn userIn)
        {
            // 임시로 만든거라 여기서 간단히 동작만 구현
            if (userIn == null)
            {
                return(Ok(new
                {
                    success = false,
                    reason = "Failed to Login",
                }));
            }

            if (_userSvc.Read(userIn.Id, out var read) == false)
            {
                return(Ok(new
                {
                    success = false,
                    reason = "Invalid Id or Password",
                }));
            }

            if (read.Password != userIn.Password)
            {
                return(Ok(new
                {
                    success = false,
                    reason = "Invalid Id or Password",
                }));
            }

            return(Ok(new
            {
                success = true,
            }));
        }
示例#2
0
        private LoginOut RealizarLoginAsync(LoginIn loginIn)
        {
            var loginOut = new LoginOut();

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(Services.UrlBase);
                    var response = client.PostAsJsonAsync(Services.UrlAutenticacao, loginIn).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        loginOut.loginValido = response.Content.ReadAsStringAsync().Result.Contains("token");
                    }
                    else
                    {
                        loginOut.Mensagem = "Usuário e/ou senha inválidos";
                    }
                }

                return(loginOut);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#3
0
        public LoginVIewModel message(LoginIn usuario)
        {
            LoginVIewModel lvm = new LoginVIewModel();
            var            v   = unitOfWork.ConsignatarioRepository.Get(x => x.Email == usuario.Login);

            if (v != null)
            {
                foreach (var item in v)
                {
                    if (!item.isEmailVerified.GetValueOrDefault())
                    {
                        lvm.message = "Please verify your email first";
                    }
                    if (string.Compare(Crypto.Hash(usuario.Password), item.AccessPassword) == 0)
                    {
                        lvm.passHash = 0;
                    }
                    else
                    {
                        lvm.message = "Invalid credential provided";
                    }
                }
            }
            else
            {
                lvm.message = "Invalid credential provided";
            }
            return(lvm);
        }
示例#4
0
        public IActionResult Login(LoginIn loginBE)
        {
            ViewBag.UsuarioInvalido = true;

            try
            {
                //var login = RealizarLogin(loginBE);
                var login = new LoginOut
                {
                    nomeUsuario = "Leticia",
                    loginValido = true
                };

                if (login.loginValido)
                {
                    HttpContext.Session.SetString(Sessions.SessionUser, login?.nomeUsuario);
                    ViewBag.Usuario         = HttpContext.Session.GetString(Sessions.SessionUser);
                    ViewBag.UsuarioInvalido = false;
                    return(RedirectToAction("Index", "Home", HttpContext.Session));
                }
            }
            catch (Exception ex)
            {
                ViewData["Message"] = $"Ocorreu um erro ao realizar o login. Por favor tente novamente. [{ex.Message}]";
            }

            return(View());
        }
示例#5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql = "";

        LoginIn.isAccount(sql);
        //第一种方法是 在UI层拼接好sql 传 BLL再传DAL
        //第二种方法是 在UI层传账号密码 到BLL层 拼接好后传到DAL层
    }
示例#6
0
        public ActionResult LoginOn(LoginIn model)
        {
            Response <bool> result = new Response <bool>();

            SetCookie(JsonConvert.SerializeObject(model));

            return(Json(result));
        }
示例#7
0
        /// <summary>
        /// 验证登录信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        private async Task <Result> VerifyLogin(LoginIn data)
        {
            Result result = new Result();

            if (data == null)
            {
                result.msg = "参数错误";
                return(result);
            }
            if (string.IsNullOrWhiteSpace(data.user_name?.Trim()))
            {
                result.msg = "用户名不能为空";
                return(result);
            }
            data.user_name = data.user_name?.Trim();
            if (string.IsNullOrWhiteSpace(data.password?.Trim()))
            {
                result.msg = "密码不能为空";
                return(result);
            }
            data.password = data.password?.Trim();

            if (!VerifyCommon.UserName(data.user_name))
            {
                result.msg = "用户名或密码错误";
                return(result);
            }
            if (data.user_name.Length < 5 || data.user_name.Length > 12)
            {
                result.msg = "用户名或密码错误";
                return(result);
            }

            if (!VerifyCommon.Password(data.password))
            {
                result.msg = "用户名或密码错误";
                return(result);
            }
            if (data.password.Length < 6 || data.password.Length > 18)
            {
                result.msg = "用户名或密码错误";
                return(result);
            }

            DBHelper db = new DBHelper();
            bool     user_exist_flag = await UserDao.IsExist(db, data.user_name);

            db.Close();
            if (!user_exist_flag)
            {
                result.msg = "用户名或密码错误";
                return(result);
            }
            result.result = true;
            return(result);
        }
示例#8
0
        public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            CommonResult result = null;

            var authcode = context.Request.Query["authcode"];
            var truecode = System.Web.HttpRuntime.Cache["authcode"];

            if (authcode.ToLower() != truecode.ToString().ToLower())
            {
                result = new CommonResult()
                {
                    ResultID = 0, Message = "验证码错误!"
                };
            }
            else
            {
                //验证用户名密码
                try
                {
                    result = LoginIn.Login(context.UserName, context.Password);
                }
                catch (Exception ex)
                {
                    result = new CommonResult()
                    {
                        ResultID = 0, Message = "用户登录发生错误!"
                    };
                    G.Util.Tool.LogHelper.Logger.Fatal(result.Message, ex);
                }
            }

            if (result.ResultID == 0)
            {
                context.SetError(result.Message);
            }
            else
            {
                var user = result.Tag as EAP_User;

                var oAuthIdentity = new ClaimsIdentity(context.Options.AuthenticationType);
                oAuthIdentity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
                oAuthIdentity.AddClaim(new Claim("UserID", user.UserID.ToString()));
                oAuthIdentity.AddClaim(new Claim("OrgId", user.OrgId.ToString()));
                oAuthIdentity.AddClaim(new Claim("POrgID_G", user.POrgID_G.ToString()));
                oAuthIdentity.AddClaim(new Claim("ORGTYPE_G", user.ORGTYPE_G.ToString()));
                oAuthIdentity.AddClaim(new Claim("RoleIDs_G", user.RoleIDs_G));

                var ticket = new AuthenticationTicket(oAuthIdentity, new AuthenticationProperties());
                context.Validated(ticket);
            }

            context.Response.Headers.Add("Access-Control-Allow-Origin", new string[] { "*" });

            return(base.GrantResourceOwnerCredentials(context));
        }
        public async Task <ActionResult <bool> > login([FromBody] LoginIn loginObject)
        {
            var result = await _customerRepository.GetAny("email", loginObject.email);

            var user = result.FirstOrDefault();

            if (user == null)
            {
                return(BadRequest());
            }
            var exists = BCrypt.Net.BCrypt.Verify(loginObject.password, user.passwordHash);

            return(Ok(exists));
        }
示例#10
0
        public async Task <string> Login(LoginIn credentials)
        {
            var response = await api.MakeRequest <LoginOut, LoginIn>(MethodType.PUT, "/api/authorization", credentials);

            var code = response.Item2;

            switch (code)
            {
            case System.Net.HttpStatusCode.OK:
                string sessionId = response.Item1.SessionId;
                return(sessionId);

            default:
                return(null);
            }
        }
示例#11
0
 public IHttpActionResult Login(LoginIn input)
 {
     if (ModelState.IsValid)
     {
         var user     = new SystemManagement.Business.Controllers.User();
         var loginOut = user.Login(input);
         return(ResponseMessage(Request.CreateResponse(System.Net.HttpStatusCode.OK, loginOut)));
     }
     else
     {
         var output = new LoginOut();
         output.result  = SystemManagement.Entities.Common.Result.Error;
         output.message = DetailErrorBadRequest(ModelState);
         return(ResponseMessage(Request.CreateResponse(System.Net.HttpStatusCode.BadRequest, output)));
     }
 }
 /// <summary>
 /// 玩家登录请求的处理方法
 /// </summary>
 /// <param name="session"></param>
 /// <param name="data"></param>
 private void _onLogin(Session session, LoginIn data)
 {
     if (_dataBaseAccess.AuthenAccount(data.UserName, data.Password, out ulong UID))
     {
         _connector.SessionBind(session, UID);
         _connector.SendDataAsync(session, new LoginInfo()
         {
             IsLogin = true, PlayerID = UID, Info = "账号登录成功!"
         });
     }
     else
     {
         _connector.SendDataAsync(session, new LoginInfo()
         {
             IsLogin = false, Info = "账号不存在或密码错误!"
         });
     }
 }
示例#13
0
        private LoginOut RealizarLogin(LoginIn loginIn)
        {
            if (loginIn is null)
            {
                throw new ArgumentNullException(nameof(loginIn));
            }

            using (var httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));

                var response = httpClient.GetStringAsync(new Uri(Services.UrlAutenticacao)).Result;

                return(new LoginOut {
                    nomeUsuario = response
                });
            }
        }
示例#14
0
        public IActionResult Login(LoginIn loginIn)
        {
            ViewBag.UsuarioInvalido = true;

            if (loginIn is null)
            {
                throw new ArgumentNullException(nameof(loginIn));
            }

            var loginOut = RealizarLoginAsync(loginIn);

            if (loginOut.loginValido)
            {
                HttpContext.Session.SetString(Sessions.SessionUser, loginIn.Login);
                ViewBag.Usuario         = HttpContext.Session.GetString(Sessions.SessionUser);
                ViewBag.UsuarioInvalido = false;
                return(RedirectToAction("Index", "Home"));
            }

            return(View());
        }
示例#15
0
        public ActionResult Index(consignatario login, string ReturnUrl = "")
        {
            UsuarioLogic ul = new UsuarioLogic();

            LoginIn li = new LoginIn
            {
                Login    = login.Email,
                Password = login.AccessPassword
            };

            var v = ul.message(li);

            if (v != null)
            {
                if (v.passHash == 0)
                {
                    return(CreaSesion(li.Login, ReturnUrl));
                }
            }

            ViewBag.Message = message;
            return(View());
        }
示例#16
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            LoginInfoLable.Content = string.Empty;
            if (!GameTCP.TcpClient.Connected)
            {
                try
                {
                    GameTCP.StartUp(IPAddress.Loopback);
                }
                catch (Exception exc)
                {
                    LoginInfoLable.Content = "无法连接服务器,请重试";
                    return;
                }
            }
            LoginIn loginIn = new LoginIn()
            {
                UserName = UsernameTextB.Text,
                Password = PasswordTextB.Password
            };

            GameTCP.SendAsync(loginIn);
        }
示例#17
0
        public IActionResult Logout(LoginIn loginIn)
        {
            HttpContext.Session.Remove(Sessions.SessionUser);

            return(RedirectToAction("Index", "Home"));
        }
 public Task Login(LoginIn loginIn)
 {
     return(GameTCPClient.SendAsync(loginIn));
 }
示例#19
0
        public LoginOut Login(LoginIn input)
        {
            var output = new LoginOut()
            {
                result = Entities.Common.Result.Error
            };
            var request    = new Business.User.User();
            var getUserOut = request.GetUser(new MethodParameters.User.GetUserIn()
            {
                usr_userName = input.usr_userName
            });

            if (getUserOut.result == Entities.Common.Result.Success)
            {
                if (getUserOut.user.usr_userName == input.usr_userName)
                {
                    var passwordIn = Common.Security.Encryption.Encrypt(input.usr_password, getUserOut.user.usr_userName);
                    var passwordBd = getUserOut.user.usr_password;

                    if (passwordIn == passwordBd)
                    {
                        string sessionId        = Guid.NewGuid().ToString();
                        var    authentication   = new SystemManagement.Business.Authentication.Authentication();
                        var    createSessionOut = authentication.CreateSession(new MethodParameters.Authentication.CreateSessionIn()
                        {
                            sessionId = sessionId,
                            userId    = getUserOut.user.usrID
                        });

                        if (createSessionOut.result == Entities.Common.Result.Success)
                        {
                            output.sessionId = sessionId;
                            output.user      = getUserOut.user;;

                            var jwtManager       = new SystemManagement.Business.Authentication.JwtManager();
                            var generateTokenOut = jwtManager.GenerateToken(new MethodParameters.Authentication.JwtManager.GenerateTokenIn()
                            {
                                sessionId = sessionId,
                                usrID     = getUserOut.user.usrID
                            });

                            if (generateTokenOut.result == Entities.Common.Result.Success)
                            {
                                output.token  = generateTokenOut.token;
                                output.user   = getUserOut.user;
                                output.result = Entities.Common.Result.Success;
                            }
                        }
                    }
                    else
                    {
                        output.message = "Credenciales incorrectas, verifique e intente nuevamente";
                    }
                }
                else
                {
                    output.message = "Credenciales incorrectas, verifique e intente nuevamente";
                }
            }
            else
            {
                output.message = "Credenciales incorrectas, verifique e intente nuevamente";
            }


            return(output);
        }
示例#20
0
 public async Task <IActionResult> Login([FromBody] LoginIn model)
 {
     return(await userApp.Login(await Package(model)));
 }