コード例 #1
0
        public IActionResult Login([FromBody] InternalUserLoginRequest internalUserLoginRequest)
        {
            try
            {
                InternalUserResponse internalUser = _internalUserService.GetInternalUserInformation(internalUserLoginRequest);
                if (internalUser == null)
                {
                    return(Unauthorized());
                }

                var tokenString = _tokenHelper.GenerateToken(internalUser);

                var organization = _organizationService.GetOrganizationByEmail(internalUser.Email);
                return(Ok(new
                {
                    Token = tokenString,
                    IsOrganization = internalUser.IsOrganization,
                    Organization = organization
                }));
            }
            catch (Exception ex)
            {
                return(Unauthorized(ex.Message));
            }
        }
コード例 #2
0
        public InternalUserResponse GetInternalUserInformation(InternalUserLoginRequest internalUserLoginRequest)
        {
            InternalUser internalUser = _unitOfWork.InternalUserRepository.FindEntity(
                x => x.Email == internalUserLoginRequest.Email && x.Password == internalUserLoginRequest.Password);



            return(_mapper.Map <InternalUserResponse>(internalUser));
        }