In the Confirm page. the Websecurity helper turns IsConfirmed to true (Webpages_Membership table) when there is a match (from email) on the token to authenticate a user.
(GetLastInsertedID() exists, maybe there are similar available)
Is there a way to know which User Id was updated by WebSecurity. Something like GetLastchangedID().
I have that UserId column linked to my own member table and need to update the status of the matching member.
Thanks
Dallas in Maryland
WebSecurity.Logout();
if (!confirmationToken.IsEmpty()) {
if (WebSecurity.ConfirmAccount(confirmationToken)) {
message = "Registration Confirmed! Click on the log in tab to log in to the site.";
//WebSecurity turned confirmed to True
//Need to change StatusId for this member to 1 (Active)
var db = Database.Open("MyDatabase");
var findmember = db.QuerySingle("SELECT MemberID, UserId, StatusId "+
" FROM Member "+
" WHERE Userid = @0 ",GetLastChangedID);
var findtoken = db.QuerySingle("SELECT UserId, ConfirmationToken "+
" FROM Webpages_Membership "+
" WHERE ConfirmationToken = @0 ", confirmationToken);
if (findtoken != null)
{// match
var findmember = db.QuerySingle("SELECT MemberId, UserId, Email "+
" FROM Member "+
" WHERE Member.UserId = @0 ",findtoken.UserId);
if (findmember != null)
{ // match
var sql="UPDATE Member SET StatusId = @0 WHERE MemberId = @1";
db.Execute(sql, 1, findmember.MemberId);
DMT20601
Member
86 Points
197 Posts
WebSecurity - GetLastChangedID
Feb 24, 2013 08:17 PM|LINK
Working with Webmatrix and the Starter Site.
In the Confirm page. the Websecurity helper turns IsConfirmed to true (Webpages_Membership table) when there is a match (from email) on the token to authenticate a user.
(GetLastInsertedID() exists, maybe there are similar available)
Is there a way to know which User Id was updated by WebSecurity. Something like GetLastchangedID().
I have that UserId column linked to my own member table and need to update the status of the matching member.
Thanks
Dallas in Maryland
WebSecurity.Logout(); if (!confirmationToken.IsEmpty()) { if (WebSecurity.ConfirmAccount(confirmationToken)) { message = "Registration Confirmed! Click on the log in tab to log in to the site."; //WebSecurity turned confirmed to True //Need to change StatusId for this member to 1 (Active) var db = Database.Open("MyDatabase"); var findmember = db.QuerySingle("SELECT MemberID, UserId, StatusId "+ " FROM Member "+ " WHERE Userid = @0 ",GetLastChangedID);wavemaster
Participant
1279 Points
1127 Posts
Re: WebSecurity - GetLastChangedID
Feb 24, 2013 11:09 PM|LINK
On a table that has is identity checked on the key, I have the follwing:
"SELECT MAX(ClientId) FROM Clients"Mikesdotnett...
All-Star
154901 Points
19864 Posts
Moderator
MVP
Re: WebSecurity - GetLastChangedID
Feb 25, 2013 05:04 AM|LINK
Just query the table for the user who has a matching confirmationToken:
var findmember = db.QuerySingle(@"SELECT MemberID, UserId, StatusId FROM Member WHERE ConfirmationToken = @0 ",confirmationToken);Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
Mikesdotnett...
All-Star
154901 Points
19864 Posts
Moderator
MVP
Re: WebSecurity - GetLastChangedID
Feb 25, 2013 05:06 AM|LINK
That will give you the highest UserId value in the table, not necessarily the one that just confirmed their account.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
DMT20601
Member
86 Points
197 Posts
Re: WebSecurity - GetLastChangedID
Feb 25, 2013 03:05 PM|LINK
This works in the Starter Site.
Thanks again.
var findtoken = db.QuerySingle("SELECT UserId, ConfirmationToken "+ " FROM Webpages_Membership "+ " WHERE ConfirmationToken = @0 ", confirmationToken); if (findtoken != null) {// match var findmember = db.QuerySingle("SELECT MemberId, UserId, Email "+ " FROM Member "+ " WHERE Member.UserId = @0 ",findtoken.UserId); if (findmember != null) { // match var sql="UPDATE Member SET StatusId = @0 WHERE MemberId = @1"; db.Execute(sql, 1, findmember.MemberId);wavemaster
Participant
1279 Points
1127 Posts
Re: WebSecurity - GetLastChangedID
Feb 25, 2013 03:05 PM|LINK
Mike, are there any other nifty tricks similar to getlastchangedid?