示例#1
0
        public async Task <AuthStudentVO> AuthUserTaskAsync(string email)
        {
            if (!(await _studentRepository.FindByEmailTaskAsync(email) is StudentModel user))
            {
                return(null);
            }

            AuthStudentVO userVO = _authStudentConverter.Parse(user);

            userVO.Token = _tokenService.Generate(user.StudentId, UserTypeEnum.Student);

            return(userVO);
        }
        public async Task <AuthCoordinatorVO> AuthAccountTaskAsync(LoginRequestModel login)
        {
            login.Password = SecurityService.EncryptToSHA256(login.Password);

            if (await _coordinatorRepository.FindUserByLoginTaskAsync(login) is CoordinatorModel user)
            {
                AuthCoordinatorVO userVO = _authCoordinatorConverter.Parse(user);
                userVO.Token = _tokenService.Generate(user.CoordinatorId, UserTypeEnum.Coordinator);

                return(userVO);
            }

            return(default);