Esempio n. 1
0
        public Task <IdentityResult> Register(RegisterUserModel model)
        {
            var user = new User
            {
                UserName       = model.Email,
                FirstName      = model.FirstName !,
                LastName       = model.LastName !,
                Email          = model.Email,
                EmailConfirmed = true
            };

            return(_identityManager.CreateAsync(user, model.Password));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Register(RegisterUser model)
        {
            // TO DO: this should go through ModelValidationAttribute or validation should go to business layer?
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            IdentityResult result = await _identityManager.CreateAsync(model);

            if (!result.Succeeded)
            {
                return(this.GetErrorResult(result));
            }

            return(Ok());
        }