Just to have a little more security and prevent any email from being registered. How to do?
Using an attribute called [EmailAddress]
in your email field. It validates perfectly if the string
is a valid email or not.
[EmailAddress]
public String MeuEnderecoDeEmail { get; set; }
The idea is after registering, send the user an email containing a link, where he can actually confirm the registration and only release the permission to log in.
For this, you need to create a default for the confirmation. For example, a token in base64
. Follow two methods to generate a token:
public static string Base64Encode(string minhaString) {
var bytes = System.Text.Encoding.UTF8.GetBytes(minhaString);
return System.Convert.ToBase64String(bytes);
}
public static string Base64Decode(string stringCriptografada) {
var bytes = System.Convert.FromBase64String(stringCriptografada);
return System.Text.Encoding.UTF8.GetString(bytes);
}
Make a method that generates a token like this (the input string you define) and save it to yours Model.
To set up an email, you can use a service like the Sendgrid that already has a good solution ready to be used. Here they teach how to assemble and send an email through their application.
You have been here for a long time, please take a look at these links http://meta.pt.stackoverflow.com/questions/1084/como-devemos-formatr-questions-e-respostas?lq=1, http://meta.pt.stackoverflow.com/questions/297/quando-se-deve-colocao-name-linguagem-no-t%C3%adtulo
– Maniero