-
Notifications
You must be signed in to change notification settings - Fork 0
4. Controllers
You can use all controller class this pattern
$whoo = new Whoo('ControllerClassName', $argumentsArray);
$whoo->success(function() {/* if everything OK, this block is running */});
$whoo->exception('ExceptionNameWithoutSuffix', function() {/* catching exceptions */})
$whoo->run();
This class provides user to create a new account. You can set username or use SetUsername class after this class.
SignUp([
email email[1:255],
str password[8:50],
str passwordAgain[8:50] (optional),
str username[1:40] (optional)
]);
Name | Precondition | Condition |
---|---|---|
NotUniqueEmailException | n/a | email is not unique in Whoo database |
UnmatchedPasswordsException | passing optional passwordAgain | password and passwordAgain are not matched |
NotUniqueUsernameException | use_username config true and passing optional username | username is not unique |
This class provides user to generate JWT using email and password. You can get generated JWT from $jwt attribute of created SignIn object. You can also check passwords that it is same or not same using passwordAgain optional key.
SignIn([
email email[1:255],
str password[8:50],
str passwordAgain[8:50] (optional)
]);
Name | Precondition | Condition |
---|---|---|
IncorrectPasswordException | n/a | password is incorrect |
NotFoundException | n/a | There is no account with this email |
NullUsernameException | deny_if_not_set_username config true | The user has not a username |
NotVerifiedEmailException | deny_if_not_verified_to_sign_in config true | The user has not verified own email. |
TwoFactorAuthEnabledException | n/a | Two-factor authentication setting of user's account is open |
UnmatchedPasswordsException | passing optional passwordAgain | password and passwordAgain are not matched |
This class provides user to generate JWT using username and password. You can get generated JWT from $jwt attribute of created SignInByUsername object. You can also check passwords that it is same or not same using passwordAgain optional key.
SignInByUsername([
str username[1:40],
str password[8:50],
str passwordAgain[8:50] (optional)
]);
Name | Precondition | Condition |
---|---|---|
IncorrectPasswordException | n/a | password is incorrect |
NotFoundException | n/a | There is no account with this email |
NotVerifiedEmailException | deny_if_not_verified_to_sign_in config true | The user has not verified own email. |
TwoFactorAuthEnabledException | n/a | Two-factor authentication setting of user's account is open |
UnmatchedPasswordsException | passing optional passwordAgain | password and passwordAgain are not matched |
This class provides user to generate JWT using OAuth2 provider. You can get generated JWT from $jwt attribute of created SignInByProvider object.
SignInByProvider([
email email[1:255],
str provider[1:255],
str providerId[1:255]
]);
Name | Precondition | Condition |
---|---|---|
SignUpByEmailException | deny_if_sign_up_before_by_email config true | The user has been registered not using provider. |
NullUsernameException | use_username config true | The user has not a username |
If you want to set username of new user after using sign up classes, you can use this class. tempToken is unique token for each new user who has not username. You can send temporary token to new user directly.
SetUsername([
str tempToken[60:60],
str username[1:40]
]);
Name | Precondition | Condition |
---|---|---|
InvalidTemporaryTokenException | n/a | tempToken is invalid |
NotUniqueUsernameException | n/a | username is not unique |
NotNullUsernameException | n/a | The user has a username |
This class provides user to generate random authentication code for to be used in VerifyEmail class. If it done successfully, you can get authentication code from attribute of created SetAuthCodeForEmailVerification object. It's name is $authCode
SetAuthCodeForEmailVerification([
email email[1:255]
]);
Name | Precondition | Condition |
---|---|---|
NotFoundException | n/a | There is no account with this email |
This class provides user to verify email of users.
VerifyEmail([
email email[1:255],
str authCode[1:10]
]);
Name | Precondition | Condition |
---|---|---|
InvalidCodeException | n/a | authCode is invalid |
TrialCountOverException | n/a | Number of attempts exceeded the trial_max_count_to_verify_email config |
TimeOutCodeException | n/a | Time of authentication code is over |
NotFoundException | n/a | There is no account with this email |
NotFoundAuthCodeException | n/a | Authentication code has not been created for this operation |
This class provides user to destroy all token created by user.
SignOut([
str jwt[1:5000]
]);
Name | Precondition | Condition |
---|---|---|
InvalidToken | n/a | jwt is invalid |
This class provides user to generate random authentication code for to be used in ResetPassword class. If it done successfully, you can get authentication code from attribute of created SetAuthCodeToResetPassword object. It's name is $authCode
SetAuthCodeToResetPassword([
email email[1:255]
]);
Name | Precondition | Condition |
---|---|---|
NotFoundException | n/a | There is no account with this email |
NotVerifiedEmailException | deny_if_not_verified_to_reset_pw config true | The user has not verified own email. |
This class provides user to reset own passwords.
ResetPassword([
email email[1:255],
str newPassword[8:50],
str authCode[1:10]
]);
Name | Precondition | Condition |
---|---|---|
InvalidCodeException | n/a | authCode is invalid |
NotFoundException | n/a | There is no account with this email |
NotFoundAuthCodeException | n/a | Authentication code has not been created for this operation |
This class provides user to change own email.
ChangeEmail([
str jwt[1:5000],
email newEmail[1:255],
str password[8:50]
]);
Name | Precondition | Condition |
---|---|---|
InvalidToken | n/a | jwt is invalid |
NotUniqueEmailException | n/a | email is not unique in Whoo database |
IncorrectPasswordException | n/a | password is incorrect |
This class provides user to change own username
ChangeUsername([
str jwt[1:5000],
str newUsername[1:40]
]);
Name | Precondition | Condition |
---|---|---|
InvalidToken | n/a | jwt is invalid |
NotUniqueUsernameException | n/a | username is not unique |
This class provides user to change own password
ChangePassword([
str jwt[1:5000],
str password[8:50],
str newPassword[8:50]
]);
Name | Precondition | Condition |
---|---|---|
InvalidToken | n/a | jwt is invalid |
IncorrectPasswordException | n/a | password is incorrect |
This class provides user to generate random authentication code for to be used in Manage2FA class. If it done successfully, you can get authentication code from attribute of created SetAuthCodeToManage2FA object. It's name is $authCode
SetAuthCodeToManage2FA([
str jwt[1:5000],
str password[8:50]
]);
Name | Precondition | Condition |
---|---|---|
InvalidToken | n/a | jwt is invalid |
IncorrectPasswordException | n/a | password is incorrect |
This class provides user to change two-factor authentication setting as true or false.
Manage2FA([
str jwt[1:5000],
str authCode[1:10],
bool open
]);
Name | Precondition | Condition |
---|---|---|
InvalidToken | n/a | jwt is invalid |
TrialCountOverException | n/a | Number of attempts exceeded the trial_max_count_to_manage_2fa config |
InvalidCodeException | n/a | authCode is invalid |
This class provides user to sign in using email if two-factor authentication setting of the user account is open
SignIn2FA([
email email[1:255],
str authCode[1:10]
]);
Name | Precondition | Condition |
---|---|---|
NotFoundException | n/a | There is no account with this email |
NotFoundAuthCodeException | n/a | Authentication code has not been created for this operation |
TrialCountOverException | n/a | Number of attempts exceeded the trial_max_count_to_sign_in_2fa config |
TimeOutCodeException | n/a | Time of authentication code is over |
InvalidCodeException | n/a | authCode is invalid |
This class provides user to sign in using username if two-factor authentication setting of the user account is open
SignInByUsername2FA([
str username[1:40],
str authCode[1:10]
]);
Name | Precondition | Condition |
---|---|---|
NotFoundException | n/a | There is no account with this email |
NotFoundAuthCodeException | n/a | Authentication code has not been created for this operation |
TrialCountOverException | n/a | Number of attempts exceeded the trial_max_count_to_sign_in_2fa config |
TimeOutCodeException | n/a | Time of authentication code is over |
InvalidCodeException | n/a | authCode is invalid |