Пример #1
0
        public IActionResult Login([FromForm] UserLogin form)
        {
            try
            {
                var user     = GetUser(form.Email);
                var Userrole = user.Role;
                var Userid   = user.Email;
                var UserName = user.Fname;

                GetTokenModel token = GetToken.getToken(Userrole, Userid, UserName);

                var text = _service.LoginUser(form);
                if (text == true)
                {
                    return(Ok(token));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch
            {
                return(BadRequest());
            }
        }
Пример #2
0
        public IActionResult loginEmail([FromBody] LoginEmail logins)
        {
            Hash hash = new Hash();

            logins.EmpPassword = hash.HashPassword(logins.EmpPassword);

            if (_service.LoginEmail(logins))
            {
                var data    = _service.GetEmployeeByEmail(logins.EmpEmail);
                var Emprole = data.PositionPId;
                var EmpName = data.EmpName;
                var Empid   = data.EmpId;



                GetTokenModel token = GetToken.getToken(Emprole, Empid, EmpName);

                return(Ok(new
                {
                    token = token.Token,
                    expiration = token.Expiretion
                }));
            }
            else
            {
                return(BadRequest("there error"));
            }
        }
Пример #3
0
        public IActionResult SignUpUser([FromForm] User user)
        {
            var Userrole = "";
            var Userid   = "";
            var UserName = "";

            if (user.Email == "*****@*****.**")
            {
                user.Role = "admin";
                Userrole  = user.Role;
                Userid    = user.Email;
                UserName  = user.Fname;
            }
            else
            {
                user.Role = "user";
                Userrole  = user.Role;
                Userid    = user.Email;
                UserName  = user.Fname;
            }



            try
            {
                var text = _service.SignUpUser(user);
                if (text > 0)
                {
                    GetTokenModel token    = GetToken.getToken(Userrole, Userid, UserName);
                    Boolean       SendCode = SendMail.SendloginCode(text.ToString(), user.Email, user.Fname);
                    return(Ok(token));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch
            {
                return(BadRequest());
            }
        }
        public IActionResult loginId([FromBody] LoginId logins)
        {
            if (_service.LoginId(logins))
            {
                var data    = _service.GetEmployeeById(logins.EmpId);
                var Emprole = data.PositionPId;
                var Empid   = data.EmpId;
                var EmpName = data.EmpName;


                GetTokenModel token = GetToken.getToken(Emprole, Empid, EmpName);

                return(Ok(new
                {
                    token = token.Token,
                    expiration = token.Expiretion
                }));
            }
            else
            {
                return(BadRequest("there error"));
            }
        }