Beispiel #1
0
        public IActionResult Do_Login(Req_Login loginItem)
        {
            var result = new ApiResult <Res_Login>(ServiceCode, "002");

            try
            {
                var result_service = _userService.Login(loginItem);

                if (result_service.IsSuccess == 1)
                {
                    TokenManager tokenManager = new TokenManager(_configuration, _userService);

                    var find_user = result_service.Data;

                    var token = tokenManager.CreateAccessToken(find_user.UserId, find_user.Name, loginItem.Username);
                    var user  = result_service.Data;

                    user.TokenKey = token.AccessToken;

                    result.Data = user;
                    result.SetSuccess("Giriş başarılı");
                }
                else
                {
                    result.Data = null;
                    result.SetError(result_service.Message, result_service.StatusCode, result_service.TrackingCode);
                }
                return(new ObjectResult(result));
            }
            catch (Exception e)
            {
                result.SetException(e);
                return(new ObjectResult(result));
            }
        }
Beispiel #2
0
        public string LoginCompany(string email, string password)
        {
            TokenManager tokenManager = new TokenManager(_options);

            if (String.IsNullOrWhiteSpace(email) || String.IsNullOrWhiteSpace(password))
            {
                return(null);
            }
            Company company = _unitOfWork.GetRepository <Company>().GetAll().SingleOrDefault(a => a.Email.Equals(email) && a.Password.Equals(password));

            if (company == null || company.Status == false)
            {
                return(null);
            }
            string tokenString = tokenManager.CreateAccessToken(new UserProfile
            {
                Email = company.Email,
                Name  = company.CompanyName,
                Role  = "Company"
            });

            return(tokenString);
        }
Beispiel #3
0
        public string LoginApplicant(string email, string password)
        {
            TokenManager tokenManager = new TokenManager(_options);

            if (String.IsNullOrWhiteSpace(email) || String.IsNullOrWhiteSpace(password))
            {
                return(null);
            }
            Applicant applicant = _unitOfWork.GetRepository <Applicant>().GetAll().SingleOrDefault(a => a.Email.Equals(email) && a.Password.Equals(password));

            if (applicant == null || applicant.Status == false)
            {
                return(null);
            }
            string tokenString = tokenManager.CreateAccessToken(new UserProfile
            {
                Email = applicant.Email,
                Name  = applicant.FullName,
                Role  = "Applicant"
            });

            return(tokenString);
        }