internal IUser Register(IAccountRegistration creds)
        {
            // encrypt the password??
            creds.Password = BCrypt.Net.BCrypt.HashPassword(creds.Password);
            //sql
            try
            {
                string Id = Guid.NewGuid().ToString();
                int    id = _db.ExecuteScalar <int>(@"
                INSERT INTO users (Id, Email, Password, Username)
                VALUES (@Id, @Email, @Password, @Username);
                SELECT LAST_INSERT_ID();
            ", new
                {
                    Id,
                    creds.Email,
                    creds.Password,
                    creds.Username
                });

                return(new User()
                {
                    Id = Id,
                    Username = creds.Username,
                    Email = creds.Email
                });
            }
            catch (MySqlException e)
            {
                throw e;
            }
        }
示例#2
0
 public RegisterController(
     IAccountRegistration registration,
     IAccountActivation activation,
     ICodeDistribution codeDistribution,
     ILogger <RegisterController> log
     )
 {
     Registration = registration;
     Activation   = activation;
     Code         = codeDistribution;
     Log          = log;
 }
示例#3
0
        public override IWebUser Register(IAccountRegistration creds)
        {
            var auth = _provider.Register(creds);

            if (auth == null)
            {
                throw new Exception("Invalid Credentials");
            }
            var user = new WebUser(auth);

            user.SetClaims();
            return(user);
        }
示例#4
0
 public IUser Register(IAccountRegistration creds)
 {
     return(_repo.Register(creds));
 }
示例#5
0
 public virtual T Register(IAccountRegistration creds)
 {
     throw new NotImplementedException();
 }