C# 클래스 Phun.Security.PhunSimpleMembershipProvider

Copied from here: https://github.com/ASP-NET-MVC/aspnetwebstack/blob/master/src/WebMatrix.WebData/SimpleMembershipProvider.cs Apache License copyright 2.0 blah blah... to support more database engine. This is one horribly big file. Somebody should be smacked with a large trout. Half way through I feel like a coding monkey, the rest of the CMS feel like it's not even this big. GRRRRR!!!!
상속: WebMatrix.WebData.ExtendedMembershipProvider
파일 보기 프로젝트 열기: noogen/phuncms 1 사용 예제들

Private Properties

프로퍼티 타입 설명
CheckPassword bool
ConnectToDatabase DapperContext
CreateOAuthTokenTableIfNeeded void
DeleteUserAndAccountInternal bool
GenerateToken string
GenerateToken string
GetHashedPassword string
GetPasswordFailureCount int
SetPassword bool
ValidateUserTable void
VerifyUserNameHasConfirmedAccount int

공개 메소드들

메소드 설명
ChangePassword ( string username, string oldPassword, string newPassword ) : bool

Processes a request to update the password for a membership user.

ChangePasswordQuestionAndAnswer ( string username, string password, string newPasswordQuestion, string newPasswordAnswer ) : bool

Processes a request to update the password question and answer for a membership user.

ConfirmAccount ( string accountConfirmationToken ) : bool

Sets the confirmed flag for the username if it is correct.

Inherited from ExtendedMembershipProvider ==> Simple Membership MUST be enabled to use this method. There is a tiny possibility where this method fails to work correctly. Two or more users could be assigned the same token but specified using different cases. A workaround for this would be to use the overload that accepts both the user name and confirmation token.

ConfirmAccount ( string userName, string accountConfirmationToken ) : bool

Sets the confirmed flag for the username if it is correct.

Inherited from ExtendedMembershipProvider ==> Simple Membership MUST be enabled to use this method

CreateAccount ( string userName, string password, bool requireConfirmationToken ) : string

When overridden in a derived class, creates a new user account using the specified user name and password, optionally requiring that the new account must be confirmed before the account is available for use.

CreateOrUpdateOAuthAccount ( string provider, string providerUserId, string userName ) : void

Creates the or update O auth account.

CreateUser ( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, MembershipCreateStatus &status ) : System.Web.Security.MembershipUser

Adds a new membership user to the data source.

CreateUserAndAccount ( string userName, string password, bool requireConfirmation, object>.IDictionary values ) : string

When overridden in a derived class, creates a new user profile and a new membership account.

DeleteAccount ( string userName ) : bool

When overridden in a derived class, deletes the specified membership account.

DeleteOAuthAccount ( string provider, string providerUserId ) : void

When overridden in a derived class, deletes the OAuth or OpenID account with the specified provider name and provider user ID.

DeleteOAuthToken ( string token ) : void

Deletes the OAuth token from the backing store from the database.

DeleteUser ( string userName, bool deleteAllRelatedData ) : bool

Removes a user from the membership data source.

FindUsersByEmail ( string emailToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection

Gets a collection of membership users where the e-mail address contains the specified e-mail address to match.

FindUsersByName ( string usernameToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection

Gets a collection of membership users where the user name contains the specified user name to match.

GeneratePasswordResetToken ( string userName, int tokenExpirationInMinutesFromNow ) : string

When overridden in a derived class, generates a password reset token that can be sent to a user in email.

GetAccountsForUser ( string userName ) : ICollection

When overridden in a derived class, returns all OAuth membership accounts associated with the specified user name.

GetAllUsers ( int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection

Gets a collection of all the users in the data source in pages of data.

GetCreateDate ( string userName ) : System.DateTime

When overridden in a derived class, returns the date and time when the specified user account was created.

GetLastPasswordFailureDate ( string userName ) : System.DateTime

When overridden in a derived class, returns the date and time when an incorrect password was most recently entered for the specified user account.

GetNumberOfUsersOnline ( ) : int

Gets the number of users currently accessing the application.

GetOAuthTokenSecret ( string token ) : string

Gets the O auth token secret.

GetPassword ( string username, string answer ) : string

Gets the password for the specified user name from the data source.

GetPasswordChangedDate ( string userName ) : System.DateTime

When overridden in a derived class, returns the date and time when the password was most recently changed for the specified membership account.

GetPasswordFailuresSinceLastSuccess ( string userName ) : int

When overridden in a derived class, returns the number of times that the password for the specified user account was incorrectly entered since the most recent successful login or since the user account was created.

GetUser ( object providerUserKey, bool userIsOnline ) : System.Web.Security.MembershipUser

Gets user information from the data source based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.

GetUser ( string username, bool userIsOnline ) : System.Web.Security.MembershipUser

Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user.

GetUserId ( string userName ) : int

Gets the user id.

GetUserIdFromOAuth ( string provider, string providerUserId ) : int

When overridden in a derived class, returns the user ID for the specified OAuth or OpenID provider and provider user ID.

GetUserIdFromPasswordResetToken ( string token ) : int

When overridden in a derived class, returns an ID for a user based on a password reset token.

GetUserNameByEmail ( string email ) : string

Gets the user name associated with the specified e-mail address.

GetUserNameFromId ( int userId ) : string

Returns the user name that is associated with the specified user ID.

HasLocalAccount ( int userId ) : bool

Determines whether there exists a local account (as opposed to OAuth account) with the specified userId.

Initialize ( string name, NameValueCollection config ) : void

Initializes the provider.

IsConfirmed ( string userName ) : bool

When overridden in a derived class, returns a value that indicates whether the user account has been confirmed by the provider.

PhunSimpleMembershipProvider ( ) : System

Initializes a new instance of the PhunSimpleMembershipProvider class.

PhunSimpleMembershipProvider ( MembershipProvider previousProvider ) : System

Initializes a new instance of the PhunSimpleMembershipProvider class.

ReplaceOAuthRequestTokenWithAccessToken ( string requestToken, string accessToken, string accessTokenSecret ) : void

Replaces the request token with access token and secret.

ResetPassword ( string username, string answer ) : string

Resets a user's password to a new, automatically generated password.

ResetPasswordWithToken ( string token, string newPassword ) : bool

When overridden in a derived class, resets a password after verifying that the specified password reset token is valid.

StoreOAuthRequestToken ( string requestToken, string requestTokenSecret ) : void

Stores the O auth request token.

UnlockUser ( string userName ) : bool

Clears a lock so that the membership user can be validated.

UpdateUser ( System.Web.Security.MembershipUser user ) : void

Updates information about a user in the data source.

ValidateUser ( string username, string password ) : bool

Verifies that the specified user name and password exist in the data source.

보호된 메소드들

메소드 설명
CreateTablesIfNeeded ( ) : void

Creates the tables if needed.

GetUserId ( DapperContext db, string userTableName, string userNameColumn, string userIdColumn, string userName ) : int

Gets the user id.

VerifyInitialized ( ) : void

Verifies the initialized.

비공개 메소드들

메소드 설명
CheckPassword ( DapperContext db, int userId, string password ) : bool

Checks the password.

ConnectToDatabase ( ) : DapperContext

Connects to database.

CreateOAuthTokenTableIfNeeded ( DapperContext db ) : void

Creates the O auth token table if needed.

DeleteUserAndAccountInternal ( string userName ) : bool

Deletes the user and account internal.

GenerateToken ( ) : string

Generates the token.

GenerateToken ( RandomNumberGenerator generator ) : string

Generates the token.

GetHashedPassword ( DapperContext db, int userId ) : string

Gets the hashed password.

GetPasswordFailureCount ( DapperContext db, int userId ) : int

Gets the password failures since last success.

SetPassword ( DapperContext db, int userId, string newPassword ) : bool

Sets the password.

ValidateUserTable ( ) : void

Validates the user table.

VerifyUserNameHasConfirmedAccount ( DapperContext db, string username, bool throwException ) : int

Verifies the user name has confirmed account.

메소드 상세

ChangePassword() 공개 메소드

Processes a request to update the password for a membership user.
/// username /// or /// oldPassword /// or /// newPassword ///
public ChangePassword ( string username, string oldPassword, string newPassword ) : bool
username string The user to update the password for.
oldPassword string The current password for the specified user.
newPassword string The new password for the specified user.
리턴 bool

ChangePasswordQuestionAndAnswer() 공개 메소드

Processes a request to update the password question and answer for a membership user.
public ChangePasswordQuestionAndAnswer ( string username, string password, string newPasswordQuestion, string newPasswordAnswer ) : bool
username string The user to change the password question and answer for.
password string The password for the specified user.
newPasswordQuestion string The new password question for the specified user.
newPasswordAnswer string The new password answer for the specified user.
리턴 bool

ConfirmAccount() 공개 메소드

Sets the confirmed flag for the username if it is correct.
Inherited from ExtendedMembershipProvider ==> Simple Membership MUST be enabled to use this method. There is a tiny possibility where this method fails to work correctly. Two or more users could be assigned the same token but specified using different cases. A workaround for this would be to use the overload that accepts both the user name and confirmation token.
public ConfirmAccount ( string accountConfirmationToken ) : bool
accountConfirmationToken string A confirmation token to pass to the authentication provider.
리턴 bool

ConfirmAccount() 공개 메소드

Sets the confirmed flag for the username if it is correct.
Inherited from ExtendedMembershipProvider ==> Simple Membership MUST be enabled to use this method
public ConfirmAccount ( string userName, string accountConfirmationToken ) : bool
userName string The user name.
accountConfirmationToken string A confirmation token to pass to the authentication provider.
리턴 bool

CreateAccount() 공개 메소드

When overridden in a derived class, creates a new user account using the specified user name and password, optionally requiring that the new account must be confirmed before the account is available for use.
///
public CreateAccount ( string userName, string password, bool requireConfirmationToken ) : string
userName string The user name.
password string The password.
requireConfirmationToken bool (Optional) true to specify that the account must be confirmed; otherwise, false. The default is false.
리턴 string

CreateOrUpdateOAuthAccount() 공개 메소드

Creates the or update O auth account.
public CreateOrUpdateOAuthAccount ( string provider, string providerUserId, string userName ) : void
provider string The provider.
providerUserId string The provider user id.
userName string Name of the user.
리턴 void

CreateTablesIfNeeded() 보호된 메소드

Creates the tables if needed.
protected CreateTablesIfNeeded ( ) : void
리턴 void

CreateUser() 공개 메소드

Adds a new membership user to the data source.
public CreateUser ( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, MembershipCreateStatus &status ) : System.Web.Security.MembershipUser
username string The user name for the new user.
password string The password for the new user.
email string The e-mail address for the new user.
passwordQuestion string The password question for the new user.
passwordAnswer string The password answer for the new user
isApproved bool Whether or not the new user is approved to be validated.
providerUserKey object The unique identifier from the membership data source for the user.
status MembershipCreateStatus A enumeration value indicating whether the user was created successfully.
리턴 System.Web.Security.MembershipUser

CreateUserAndAccount() 공개 메소드

When overridden in a derived class, creates a new user profile and a new membership account.
public CreateUserAndAccount ( string userName, string password, bool requireConfirmation, object>.IDictionary values ) : string
userName string The user name.
password string The password.
requireConfirmation bool (Optional) true to specify that the user account must be confirmed; otherwise, false. The default is false.
values object>.IDictionary (Optional) A dictionary that contains additional user attributes to store in the user profile. The default is null.
리턴 string

DeleteAccount() 공개 메소드

When overridden in a derived class, deletes the specified membership account.
public DeleteAccount ( string userName ) : bool
userName string The user name.
리턴 bool

DeleteOAuthAccount() 공개 메소드

When overridden in a derived class, deletes the OAuth or OpenID account with the specified provider name and provider user ID.
public DeleteOAuthAccount ( string provider, string providerUserId ) : void
provider string The name of the OAuth or OpenID provider.
providerUserId string The OAuth or OpenID provider user ID. This is not the user ID of the user account, but the user ID on the OAuth or Open ID provider.
리턴 void

DeleteOAuthToken() 공개 메소드

Deletes the OAuth token from the backing store from the database.
public DeleteOAuthToken ( string token ) : void
token string The token to be deleted.
리턴 void

DeleteUser() 공개 메소드

Removes a user from the membership data source.
public DeleteUser ( string userName, bool deleteAllRelatedData ) : bool
userName string Name of the user.
deleteAllRelatedData bool true to delete data related to the user from the database; false to leave data related to the user in the database.
리턴 bool

FindUsersByEmail() 공개 메소드

Gets a collection of membership users where the e-mail address contains the specified e-mail address to match.
public FindUsersByEmail ( string emailToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
emailToMatch string The e-mail address to search for.
pageIndex int The index of the page of results to return. is zero-based.
pageSize int The size of the page of results to return.
totalRecords int The total number of matched users.
리턴 System.Web.Security.MembershipUserCollection

FindUsersByName() 공개 메소드

Gets a collection of membership users where the user name contains the specified user name to match.
public FindUsersByName ( string usernameToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
usernameToMatch string The user name to search for.
pageIndex int The index of the page of results to return. is zero-based.
pageSize int The size of the page of results to return.
totalRecords int The total number of matched users.
리턴 System.Web.Security.MembershipUserCollection

GeneratePasswordResetToken() 공개 메소드

When overridden in a derived class, generates a password reset token that can be sent to a user in email.
Argument cannot be null or empty.;userName Unable to update simple membership database.
public GeneratePasswordResetToken ( string userName, int tokenExpirationInMinutesFromNow ) : string
userName string The user name.
tokenExpirationInMinutesFromNow int (Optional) The time, in minutes, until the password reset token expires. The default is 1440 (24 hours).
리턴 string

GetAccountsForUser() 공개 메소드

When overridden in a derived class, returns all OAuth membership accounts associated with the specified user name.
public GetAccountsForUser ( string userName ) : ICollection
userName string The user name.
리턴 ICollection

GetAllUsers() 공개 메소드

Gets a collection of all the users in the data source in pages of data.
public GetAllUsers ( int pageIndex, int pageSize, int &totalRecords ) : System.Web.Security.MembershipUserCollection
pageIndex int The index of the page of results to return. is zero-based.
pageSize int The size of the page of results to return.
totalRecords int The total number of matched users.
리턴 System.Web.Security.MembershipUserCollection

GetCreateDate() 공개 메소드

When overridden in a derived class, returns the date and time when the specified user account was created.
public GetCreateDate ( string userName ) : System.DateTime
userName string The user name of the account.
리턴 System.DateTime

GetLastPasswordFailureDate() 공개 메소드

When overridden in a derived class, returns the date and time when an incorrect password was most recently entered for the specified user account.
public GetLastPasswordFailureDate ( string userName ) : System.DateTime
userName string The user name of the account.
리턴 System.DateTime

GetNumberOfUsersOnline() 공개 메소드

Gets the number of users currently accessing the application.
public GetNumberOfUsersOnline ( ) : int
리턴 int

GetOAuthTokenSecret() 공개 메소드

Gets the O auth token secret.
public GetOAuthTokenSecret ( string token ) : string
token string The token.
리턴 string

GetPassword() 공개 메소드

Gets the password for the specified user name from the data source.
public GetPassword ( string username, string answer ) : string
username string The user to retrieve the password for.
answer string The password answer for the user.
리턴 string

GetPasswordChangedDate() 공개 메소드

When overridden in a derived class, returns the date and time when the password was most recently changed for the specified membership account.
public GetPasswordChangedDate ( string userName ) : System.DateTime
userName string The user name of the account.
리턴 System.DateTime

GetPasswordFailuresSinceLastSuccess() 공개 메소드

When overridden in a derived class, returns the number of times that the password for the specified user account was incorrectly entered since the most recent successful login or since the user account was created.
public GetPasswordFailuresSinceLastSuccess ( string userName ) : int
userName string The user name of the account.
리턴 int

GetUser() 공개 메소드

Gets user information from the data source based on the unique identifier for the membership user. Provides an option to update the last-activity date/time stamp for the user.
public GetUser ( object providerUserKey, bool userIsOnline ) : System.Web.Security.MembershipUser
providerUserKey object The unique identifier for the membership user to get information for.
userIsOnline bool true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.
리턴 System.Web.Security.MembershipUser

GetUser() 공개 메소드

Gets information from the data source for a user. Provides an option to update the last-activity date/time stamp for the user.
public GetUser ( string username, bool userIsOnline ) : System.Web.Security.MembershipUser
username string The name of the user to get information for.
userIsOnline bool true to update the last-activity date/time stamp for the user; false to return user information without updating the last-activity date/time stamp for the user.
리턴 System.Web.Security.MembershipUser

GetUserId() 보호된 메소드

Gets the user id.
protected GetUserId ( DapperContext db, string userTableName, string userNameColumn, string userIdColumn, string userName ) : int
db DapperContext The db.
userTableName string Name of the user table.
userNameColumn string The user name column.
userIdColumn string The user id column.
userName string Name of the user.
리턴 int

GetUserId() 공개 메소드

Gets the user id.
public GetUserId ( string userName ) : int
userName string Name of the user.
리턴 int

GetUserIdFromOAuth() 공개 메소드

When overridden in a derived class, returns the user ID for the specified OAuth or OpenID provider and provider user ID.
public GetUserIdFromOAuth ( string provider, string providerUserId ) : int
provider string The name of the OAuth or OpenID provider.
providerUserId string The OAuth or OpenID provider user ID. This is not the user ID of the user account, but the user ID on the OAuth or Open ID provider.
리턴 int

GetUserIdFromPasswordResetToken() 공개 메소드

When overridden in a derived class, returns an ID for a user based on a password reset token.
public GetUserIdFromPasswordResetToken ( string token ) : int
token string The password reset token.
리턴 int

GetUserNameByEmail() 공개 메소드

Gets the user name associated with the specified e-mail address.
public GetUserNameByEmail ( string email ) : string
email string The e-mail address to search for.
리턴 string

GetUserNameFromId() 공개 메소드

Returns the user name that is associated with the specified user ID.
public GetUserNameFromId ( int userId ) : string
userId int The user ID to get the name for.
리턴 string

HasLocalAccount() 공개 메소드

Determines whether there exists a local account (as opposed to OAuth account) with the specified userId.
public HasLocalAccount ( int userId ) : bool
userId int The user id to check for local account.
리턴 bool

Initialize() 공개 메소드

Initializes the provider.
config
public Initialize ( string name, NameValueCollection config ) : void
name string The friendly name of the provider.
config System.Collections.Specialized.NameValueCollection A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.
리턴 void

IsConfirmed() 공개 메소드

When overridden in a derived class, returns a value that indicates whether the user account has been confirmed by the provider.
userName
public IsConfirmed ( string userName ) : bool
userName string The user name.
리턴 bool

PhunSimpleMembershipProvider() 공개 메소드

Initializes a new instance of the PhunSimpleMembershipProvider class.
public PhunSimpleMembershipProvider ( ) : System
리턴 System

PhunSimpleMembershipProvider() 공개 메소드

Initializes a new instance of the PhunSimpleMembershipProvider class.
public PhunSimpleMembershipProvider ( MembershipProvider previousProvider ) : System
previousProvider System.Web.Security.MembershipProvider The previous provider.
리턴 System

ReplaceOAuthRequestTokenWithAccessToken() 공개 메소드

Replaces the request token with access token and secret.
public ReplaceOAuthRequestTokenWithAccessToken ( string requestToken, string accessToken, string accessTokenSecret ) : void
requestToken string The request token.
accessToken string The access token.
accessTokenSecret string The access token secret.
리턴 void

ResetPassword() 공개 메소드

Resets a user's password to a new, automatically generated password.
public ResetPassword ( string username, string answer ) : string
username string The user to reset the password for.
answer string The password answer for the specified user.
리턴 string

ResetPasswordWithToken() 공개 메소드

When overridden in a derived class, resets a password after verifying that the specified password reset token is valid.
newPassword
public ResetPasswordWithToken ( string token, string newPassword ) : bool
token string A password reset token.
newPassword string The new password.
리턴 bool

StoreOAuthRequestToken() 공개 메소드

Stores the O auth request token.
public StoreOAuthRequestToken ( string requestToken, string requestTokenSecret ) : void
requestToken string The request token.
requestTokenSecret string The request token secret.
리턴 void

UnlockUser() 공개 메소드

Clears a lock so that the membership user can be validated.
public UnlockUser ( string userName ) : bool
userName string The membership user whose lock status you want to clear.
리턴 bool

UpdateUser() 공개 메소드

Updates information about a user in the data source.
public UpdateUser ( System.Web.Security.MembershipUser user ) : void
user System.Web.Security.MembershipUser A object that represents the user to update and the updated information for the user.
리턴 void

ValidateUser() 공개 메소드

Verifies that the specified user name and password exist in the data source.
/// username /// or /// password ///
public ValidateUser ( string username, string password ) : bool
username string The name of the user to validate.
password string The password for the specified user.
리턴 bool

VerifyInitialized() 보호된 메소드

Verifies the initialized.
Initialize must be called first.
protected VerifyInitialized ( ) : void
리턴 void