// Register is always used for someone not in the database, only first time User or first time Asset use this method public async Task <AccountResult> RegisterUser(RegistrationModelBase model) { UserProfile profile; User user = null; switch (model.Type) { case IdentityTypes.USER: profile = new UserProfile(model as UserRegistrationModel); user = new User(model as UserRegistrationModel, profile); break; case IdentityTypes.BIKE_MESSENGER: case IdentityTypes.CNG_DRIVER: profile = new AssetProfile(model as AssetRegistrationModel); user = new Asset(model as AssetRegistrationModel, profile as AssetProfile); break; case IdentityTypes.ENTERPRISE: var enterpriseProfile = new EnterpriseUserProfile(model as EnterpriseUserRegistrationModel); user = new EnterpriseUser(model as EnterpriseUserRegistrationModel, enterpriseProfile); break; } var identityResult = await accountManager.CreateAsync(user, model.Password); var creationResult = new AccountResult(identityResult, user); return(creationResult); }
// Register is always used for someone not in the database, only first time User or first time Asset use this method public async Task<AccountResult> RegisterUser(RegistrationModelBase model) { UserProfile profile; User user = null; switch (model.Type) { case IdentityTypes.USER: profile = new UserProfile(model as UserRegistrationModel); user = new User(model as UserRegistrationModel, profile); break; case IdentityTypes.BIKE_MESSENGER: case IdentityTypes.CNG_DRIVER: profile = new AssetProfile(model as AssetRegistrationModel); user = new Asset(model as AssetRegistrationModel, profile as AssetProfile); break; case IdentityTypes.ENTERPRISE: var enterpriseProfile = new EnterpriseUserProfile(model as EnterpriseUserRegistrationModel); user = new EnterpriseUser(model as EnterpriseUserRegistrationModel, enterpriseProfile); break; } var identityResult = await accountManager.CreateAsync(user, model.Password); var creationResult = new AccountResult(identityResult, user); return creationResult; }
protected User(RegistrationModelBase model) { this.UserName = model.UserName; this.Email = model.Email; this.PhoneNumber = model.PhoneNumber; this.Type = model.Type; // FIXME: We need to do something about this // Emails need to be verified if (string.IsNullOrEmpty(Email)) this.EmailConfirmed = false; //FIXME: This we would probably change when we figure out how we are actually authenticating them if (string.IsNullOrEmpty(PhoneNumber)) this.PhoneNumberConfirmed = false; }
public async Task<IHttpActionResult> Register(RegistrationModelBase userModel) { if (!ModelState.IsValid) return BadRequest(ModelState); var result = await accountContext.RegisterUser(userModel); if (!result.Result.Succeeded) { return GetErrorResult(result.Result); } await accountContext.NotifyUserCreationByMail(result.User); return Created<UserModel>(Url.Link(AppConstants.GetUserProfileByIdRoute, new { userId = result.User.Id }), result.User.ToModel(isUserAuthenticated: false)); }
protected User(RegistrationModelBase model) { this.UserName = model.UserName; this.Email = model.Email; this.PhoneNumber = model.PhoneNumber; this.Type = model.Type; // FIXME: We need to do something about this // Emails need to be verified if (string.IsNullOrEmpty(Email)) { this.EmailConfirmed = false; } //FIXME: This we would probably change when we figure out how we are actually authenticating them if (string.IsNullOrEmpty(PhoneNumber)) { this.PhoneNumberConfirmed = false; } }
public async Task <IHttpActionResult> Register(RegistrationModelBase userModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await accountContext.RegisterUser(userModel); if (!result.Result.Succeeded) { return(GetErrorResult(result.Result)); } var clientSettings = AppSettings.Get <ClientSettings>(); clientSettings.Validate(); await accountContext.NotifyUserCreationByMail(result.User, clientSettings.WebCatUrl, clientSettings.ConfirmEmailPath, EmailTemplatesConfig.WelcomeEmailTemplate); return(Created <UserModel>(Url.Link(AppConstants.GetUserProfileByIdRoute, new { userId = result.User.Id }), result.User.ToModel(isUserAuthenticated: false))); }
protected User(RegistrationModelBase model, IdentityProfile profile): this(model) { this.Profile = profile; }
protected User(RegistrationModelBase model, IdentityProfile profile) : this(model) { this.Profile = profile; }