Hello,
I was wanting to use an attribute in some of my class methods that would make sure that the user is an authorized before using the method that they called.I was wanting to do something like
[Authorized()]
public void updateSomething()
{
//TODO:
}
Here is my attribute class
[
class AuthorizedAttribute : Attribute
{
public bool IsAuthorized { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string UserEmail { get; set; }
public AuthorizedAttribute()
{
//This is not the actual implementation
this.IsAuthorized = false;
}
public AuthorizedAttribute(string userEmail, string userPassword)
{
this.UserEmail = userEmail;
this.Password = userPassword;
this.UserName = string.Empty;
BusinessLogic bc = new BusinessLogic();
if (bc.VerifyCredentials(userEmail, userPassword))
{
this.IsAuthorized = true;
}
else
{
this.IsAuthorized = false;
}
}
}
Could someone point me in the right direction? Some link would be great as well.
Thank you.
Loading
VulpesPosted Jul 27, 2011, 4:09 PM
The output should be:
shams khanPosted Aug 5, 2011, 7:55 AM
Jonathas SucupiraPosted Jul 28, 2011, 8:33 AM