Reputation: 414
If a user wants to delete his/her account, while in session, I guess that you need to enter your password again to verify identity just in case. Here is my SQL code:
CREATE PROC spDeleteAccount @Password nvarchar(100) -- I'm expecting a password input to verify identity again AS BEGIN IF (@Password IS NOT NULL) -- If user exists BEGIN DELETE FROM tblUsers WHERE Password = @Password SELECT 1 AS ReturnCode END ELSE -- If user doesn't exist BEGIN SELECT 0 AS ReturnCode END END
Is this the right way to do it?
For the ASP part: What happens with the session in ASP.NET? Does it become null?
Upvotes: 0
Views: 750
Reputation: 5306
Since you asked about the right (I would say common) way I suggest you the following :
Don't do any attempt on deleting an account specially when the user is logged-in but ask for their confirmation to de-activate it. When you get the confirmation then deactivate the account so that's for the common strategy.
Now what, Lets say 1000 users of your system have deactivated? What should happen next?
Have a service or a Query job in place that after certain days of deactivation it will perform the actual deletion of the account.
How to delete an ASP.NET user?
This is fairly broad and depending on the structure of your system, different queries are required but if you insist on deleting the user then you should delete all related child tables records then delete the record itself.
Consider using ASP.NET Identity so you wont reinvent the wheel.
Upvotes: 0