Beispiel #1
0
        public async Task SingUp(BuilderDTO builderDTO)
        {
            Builder builder = await _builderRepository.GetBuilder(builderDTO.Email);

            if (null == builder)
            {
                string hashedPassword = _hashPasswordService.GenerateHashForPassword(builderDTO.Password);
                builder          = _mapper.Map <Builder>(builderDTO);
                builder.Password = hashedPassword;
                await _builderRepository.CreateBuilder(builder);
            }
        }
        public async Task <string> SingIn(BuilderDTO builderDTO)
        {
            Builder builder = await _builderRepository.GetBuilder(builderDTO.Email);

            if ((null != builder) && (_hashPasswordService.CheckPassword(builderDTO.Password, builder.Password)))
            {
                builderDTO.Id = builder.Id;
                return(GenerateJWTToken(builder));
            }
            else
            {
                return(null);
            }
        }