public CreatedUserDTO Create( string name, string cpf, string email, string phone, string state, string city, string district, string zipCode, string houseNumber, string addressComplement, UserProfile profile, string password ) { var crypt = new Crypt(); var cryptPassword = crypt.CreateMD5(password); var user = new User(name, cpf, email, phone, state, city, district, zipCode, houseNumber, addressComplement, profile, cryptPassword); var userValidation = user.Validate(); if (userValidation.isValid) { _usersRepository.Add(user); return(new CreatedUserDTO(user.Id)); } return(new CreatedUserDTO(userValidation.errors)); }
public void Configure(EntityTypeBuilder <User> builder) { var crypt = new Crypt(); var cryptPassword = crypt.CreateMD5("123"); builder.HasData(new User( "Sys Admin", cryptPassword, "*****@*****.**", UserProfile.CBF )); builder .Property(user => user.Name) .IsRequired() .HasMaxLength(100); builder .Property(user => user.Email) .IsRequired() .HasMaxLength(250); builder .Property(user => user.Password) .IsRequired() .HasMaxLength(50); builder .HasIndex(user => user.Email) .IsUnique(); }
public AuthResponse Login(string email, string password) { var user = _usersRepository.Get(x => x.Email == email); if (user == null) { return(new AuthResponse()); } var crypt = new Crypt(); var cryptPassword = crypt.CreateMD5(password); return(user.Password == cryptPassword ? new AuthResponse(user.Id) : new AuthResponse()); }
public CreatedUserDTO Create( string name, Profile profile, string email, string password ) { var crypt = new Crypt(); var cryptPassword = crypt.CreateMD5(password); var user = new User(name, cryptPassword, email, profile); var userValidation = user.Validate(); if (userValidation.isValid) { _usersRepository.Add(user); return(new CreatedUserDTO(user.Id)); } return(new CreatedUserDTO(userValidation.errors)); }
public AuthResponse Login(string email, string password) { var user = _usersRepository.Get(x => x.Email == email); if (user == null) { return(new AuthResponse()); } var crypt = new Crypt(); var cryptPassword = crypt.CreateMD5(password); if (user.Password != cryptPassword) { return(new AuthResponse()); } var token = _tokenService.GenerateToken(user); return(new AuthResponse(token)); }
public void Configure(EntityTypeBuilder <User> builder) { var crypt = new Crypt(); var cryptPassword = crypt.CreateMD5("admin123"); builder.HasData(new User( "System Admin", "24068108013", "*****@*****.**", "47999999999", "SC", "Blumenau", "Centro", "89000000", "999", "Casa", UserProfile.Admin, cryptPassword )); builder .Property(user => user.Name) .IsRequired() .HasMaxLength(100); builder .Property(user => user.CPF) .HasMaxLength(15); builder .Property(user => user.Email) .IsRequired() .HasMaxLength(100); builder .Property(user => user.Phone) .HasMaxLength(20); builder .Property(user => user.State) .HasMaxLength(2); builder .Property(user => user.City) .HasMaxLength(50); builder .Property(user => user.District) .HasMaxLength(50); builder .Property(user => user.ZipCode) .HasMaxLength(10); builder .Property(user => user.HouseNumber) .HasMaxLength(10); builder .Property(user => user.AddressComplement) .HasMaxLength(100); builder .Property(user => user.Profile) .HasMaxLength(100); builder .Property(user => user.Password) .IsRequired() .HasMaxLength(50); builder .HasIndex(user => user.Email) .IsUnique(); }