7. ABPZero series Tutorials: how to modify the registration function of a seller's tools and abpzero modification and Registration

Source: Internet
Author: User
Tags mailmessage

7. ABPZero series Tutorials: how to modify the registration function of a seller's tools and abpzero modification and Registration

This article begins with a major event. The previous articles are all about preparing for the current function. In the previous tutorial, we have discussed modifying the User table structure. Next we need to modify the registration logic code.

Registration page

Modify Register. cshtml with the following code:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Web \ Views \ Account \ Register. cshtml

 

@*<p class="hint">        @L("PersonalInformations")    </p>    <div class="form-group">        <label class="control-label visible-ie8 visible-ie9">@L("Name")</label>        <input class="form-control placeholder-no-fix" type="text" placeholder="@L("Name")" name="Name" required value="@Model.Name" maxlength="@MyCompanyName.AbpZeroTemplate.Authorization.Users.User.MaxNameLength" />    </div>    <div class="form-group">        <label class="control-label visible-ie8 visible-ie9">@L("Surname")</label>        <input class="form-control placeholder-no-fix" type="text" placeholder="@L("Surname")" name="Surname" required value="@Model.Surname" maxlength="@MyCompanyName.AbpZeroTemplate.Authorization.Users.User.MaxSurnameLength" />    </div>    <div class="form-group">        <label class="control-label visible-ie8 visible-ie9">@L("EmailAddress")</label>        <input class="form-control placeholder-no-fix" type="email" placeholder="@L("EmailAddress")" name="EmailAddress" required value="@Model.EmailAddress" maxlength="@MyCompanyName.AbpZeroTemplate.Authorization.Users.User.MaxEmailAddressLength" />    </div>*@

 

 

Copy the relevant code of the EmailAddress input box to "account settings ".

<div class="form-group">            <label class="control-label visible-ie8 visible-ie9">@L("EmailAddress")</label>            <input class="form-control placeholder-no-fix" type="email" placeholder="@L("EmailAddress")" name="EmailAddress" required value="@Model.EmailAddress" maxlength="@MyCompanyName.AbpZeroTemplate.Authorization.Users.User.MaxEmailAddressLength" />        </div>

 

Save and view, as shown in

 

Modify RegisterViewModel. cs. Note the following code:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Web \ Models \ Account \ RegisterViewModel. cs

 

//[Required]        //[StringLength(User.MaxNameLength)]        //public string Name { get; set; }        //[Required]        //[StringLength(User.MaxSurnameLength)]        //public string Surname { get; set; }

 

 

Modify AccountController. cs. Note the following code:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Web \ Controllers \ AccountController. cs

403 line code remarks:

var user = new User                {                    TenantId = tenant.Id,                    //Name = model.Name,                    //Surname = model.Surname,                    EmailAddress = model.EmailAddress,                    IsActive = isNewRegisteredUserActiveByDefault                };

 

876 line code remarks:

var viewModel = new RegisterViewModel            {                TenancyName = tenancyName,                EmailAddress = loginInfo.Email,                //Name = name,                //Surname = surname,                IsExternalLogin = true            };

 

AbpZeroTemplate-zh-CN.xml files Add the following key-value pairs:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Core \ Localization \ AbpZeroTemplate \ AbpZeroTemplate-zh-CN.xml

<Text name = "EmailRegister" value = "email registration"/>

Account \ Register. cshtml, modify the following code:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Web \ Views \ Account \ Register. cshtml

 

 

Generate a project and register a test to see the results

 

 

You can see that the registration is successful and the activation email is sent. Next, modify the page of the above two figures.

Modify RegisterResult. cshtml and note the following code:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Web \ Views \ Account \ RegisterResult. cshtml

 

<ul>    @*<li><span class="text-muted">@L("NameSurname"):</span> @Model.NameAndSurname</li>    <li><span class="text-muted">@L("TenancyName"):</span> @Model.TenancyName</li>*@    <li><span class="text-muted">@L("UserName"):</span> @Model.UserName</li>    <li><span class="text-muted">@L("EmailAddress"):</span> @Model.EmailAddress</li></ul>

 

 

Modify UserEmailer. cs and note the following code:

File Path: D: \ abp version \ aspnet-zero-3.4.0 \ aspnet-zero-3.4.0 \ src \ MyCompanyName. AbpZeroTemplate. Core \ Authorization \ Users \ UserEmailer. cs

 

//mailMessage.AppendLine("<b>" + L("NameSurname") + "</b>: " + user.Name + " " + user.Surname + "<br />");            //if (!tenancyName.IsNullOrEmpty())            //{            //    mailMessage.AppendLine("<b>" + L("TenancyName") + "</b>: " + tenancyName + "<br />");            //}

 

 

Generate a project, delete the registered account from the database, and re-register the account. The effect is as follows:

 

 

Note: The domain name port is modified in the web. config file. The integration module will talk about this configuration later. To activate the account, replace it with the port configured on IIS.

 

 

Copy and activate the connection, change the port number to the port number configured in IIS, and access the browser, as shown in. This indicates that the account has been activated successfully and can be logged on normally.

 

As you can see, there is no menu after logon, because account registration is a User role by default, and I did not grant the User role any permissions.

Now, the email registration function has been modified, and the next step is to add the Mobile Phone registration function.

 

Total returned directory

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.