I want to simply get in my code if the user has his email confirmed or not. Without an async method. Can someone help me please?
Couple of options, if i understood your question correctly:
In your database add another 2 columns "EmailConfirmationID" perhaps of type GUID (UniqueIdentifier) and Verified (bit). When the user registers you can insert a new value into EmailConfirmationID send this link to the user (creating a URL) via email. When they click this link within the email you would have the page handle their request and set Verified to true.
Have a look at this link http://www.asp.net/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity
Related
I have this code in order to get the email
string code = Request.QueryString["code"];
if (!string.IsNullOrEmpty(code)){
string data = FaceBookConnect.Fetch(code, "me");
FaceBookUser faceBookUser = new JavaScriptSerializer().Deserialize<FaceBookUser>(data);
And on the click event I defined this:
FaceBookConnect.Authorize("email", Request.Url.AbsoluteUri.Split('?')[0]);
The problem is that it gives me a null value as email, i tried doing the same for the name and it is the only field that actually works. I read that thay have changed the version to v2.6 and it is necessary to do the facebookConnect.Fetch in another way, but I am unable to find how. Anyone knows something? Thanks everyone!
Have you requested the email info from Facebook? You must do that at start of login and the user has to approve this before Facebook will provide it. Facebook also says it will be null if the address is not valid or if they used a phone number to sign up:
"Note, even if you request the email permission it is not guaranteed you will get an email address. For example, if someone signed up for Facebook with a phone number instead of an email address, the email field may be empty."
https://developers.facebook.com/docs/facebook-login/permissions#reference-email
I have a scenario here whereby when a user wants to reset a password, the system will have to send a temporary random generated password to the user by email. I tried storing the temporary password into a new column in the database but I am not really sure about whether this approach works well. Some people recommend using token such as below:
string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
However, I am really new to ASP.NET and I am not familiar with token. How do I compare the temporary generated token with the token in the database?
Another method that I found to implement this is to have a Membership.GeneratePassword function that generates a random string of characters:
model.temppwd = Membership.GeneratePassword(10, 1);
Can anybody provide me an ideal way to implement this functionality with some example? Thank you!
In our project we used
Guid.NewGuid();
and sent the email containing the link to the recover password action (MVC) as a query string: https://yoursite.com/account/reset/?code=your_guid_code
Example:
ResetPassword resetPassword = new resetPassword();
resetPassword.Code = Guid.NewGuid();
string strLink = string.Format("{0}", actionUrl + "?code="+ resetPassword.Code);`
And now you can use the strLink to send with your e-mail. You'll need to store the Guid in a database table alongside with the userId, so that you can implement the resetting procedure. When the user clicks the link from your email he'll get in a form / view that asks for a new password. Also you'll want to add an extra column to that table in order to provide an expiration limit for that code. If the user clicks the link in the e-mail and the code expired you'll have to inform the user and send another e-mail with another code.
I have been researching up creating my own link to PayPal, that when a person is logged in, it will generate a "specified email" in the "To:" text box on the form.
However, I am planning something a tad more ambitious; I'd like to know it is possible to build this link in my code to where the specified email "cannot be edited or changed?" Again, this would coming from my custom-made link:
https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email=SomePresetEmail#mail.com
How can I code this to set "SomePresetEmail#mail.com" to be static? Or is that even possible for me to do that, being I am not editing the code on Paypal's server side? My site is currently built using Asp.Net WebForms.
DesignerMind,
I am not sure if I am following you correctly. But this link is displayed on the page to user and you want them to not be able to change the email?
Is it possible to have your link point to an address inside your application that gets redirected to Paypal? When paypal recieves the request, they execute an internal mechanism to hash the request into a secured request variable. This means that when you navigate to the link the user is not seeing the actual link but a hashed version. A sample of the paypal hashed version is.
https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=Itqgb8iQ3mW92FT9ldzgcFmJyRVQLUpE2u9UMqeKbGmvwdMTY80oBEmo0SS&dispatch=5885d80a13c0db1f8e263663d3faee8def8934b92a630e40b7fef61ab7e9fe63
Now you could try to do this such as.
On your aspx.net page.
<asp:HyperLink runat="server" ID="paypalLink" NavigateUrl="~/Paypal.aspx" />
or simply
Paypal
And in the Paypal.Aspx code
static string SecretEmail = "someone#somewhere.com",
PaypalRedirectFormat = "https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email={0}";
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect(string.Format(PaypalRedirectFormat, SecretEmail));
}
This is just an idea and actually if this is what you wanted a GenericHandler would do the job quite nicely.
Let me know if this is not what you are looking for.
What i want to do is when we click on Reply button , the From address field will be populate with the email-id (default team's default queue's email-id). Current scenario is populated with logged in user.
You can create script which will be executed onLoad of email form. Check is it 'Replay' action (Url will contain _InReplyToId parameter). Find queue from original email using his GUID from url, and set it to From field.
EDIT:
This example will solve your problem :)
I have a registration form and want to transfer the user to the success page, telling him that an email was sent to his email. I need to transfer his email from the register page to the success page.
I found about Server.Transfer, but I can't find out how to send parameters. I don't want to use query string as I don't like revealing information in the URL.
What is the proper way (if possible) to do this?
Server.Transfer("destination.aspx", true)
You might see that the above code contains the name of the page to which the control is transferred and a Boolean value ‘True’ to indicate to preserve the current form state in the destination page.
Set a property in your login page and store in it, the email.
Once this is done, do a Server.Transfer("~/SuccessPage.aspx", true);
On the other page, where you redirected, you should check something like that :
if(this.PreviousPage != null) {
((LoginPageType)this.PreviousPage).MyEmailProperty;
}
When you using server transfer you just move execution to different server handler , user will no see the new url or the parameters so it safe to make this transfer.
I would rather recommend that you do it differently.
When the user clicks the register button, you verify it all and then send the email from the still current page (so you need not transfer data to another page at all). If all went well, you just redirect:
Response.Redirect("/order/success.aspx");
If something was wrong (validation errors, sending email caused an exception) you are still on the right page for a retry. I would not use Server.Transfer at all in most cases.
You'll have to persist the value somewhere. The obvious options are in the Session object, or in a database.
For this kind of use case. You can use Context.Items to save the data with a key and read the value using the same key in the child page you are doing the Server.Transfer. Context.Items are sort of per request scoped cache for you.
Context.Items['DataKey'] = Data;
Server.Transfer("~/AnyRouteRelativePath", true);