-
Notifications
You must be signed in to change notification settings - Fork 0
4. Features
This feature is regarding user validation. In ramenauth, we are using two kind of rules. First is rules which is defined inside ramenauth config file, located at config/ramenauth.php. If you are not defined the rules in configuration file, you can defined the rules inside the model class itself.The rules is covering all of model class attributes validation, like username, password, email, phone, etc. You can also define which method will access which rules. The rules is a JSON Object, and example of rules are following:
protected $rules = [
"store" => [
"first_name" => "required",
"phone" => "required_without:email|unique:users|min:7",
"username" => "unique:users|min:5",
"email" => "required_without:phone|unique:users|email",
"password" => "sometimes|confirmed|min:4",
],
"update" => [],
];
store is the key which will be used to call the rules from methods. and then it contains of JSON Object which defines the attributes and their individual rules.
There is two type of verification in ramenauth, phone and email verification. You can choose one to set as primary verification, and that automatically made the other one as secondary verification. To set primary verification in your app, you need to define it inside of config/ramenauth.php. You can add primary_verification => 'email' to set email as primary verification method.
You can find the configuration for SMS verification in config/ramenauth.php. You can change the configuration by directly changing the configuration file. But also, you can override these settings by defining the necessary parameter into your .env file. By default, ramenauth is using nexmo as SMS Gateway provider. The parameters are designed to be fail-safe, providing a default value if you are not setting it in your .env file.Therefore, some parameters like sms_verification_api_key, sms_verification_api_secret, and sms_verification_title didn't have any default value, so you must set those parameters in your .env file.
You can also use ramenauth to generate user token associate to your apps. ramenauth using JWT as type of token.
ramenauth utilizing two method for doing password recovery, by email or phone. The method is defined in the endpoints if you are using the default routing. Password recovery process in ramenauth is divided into three separate function.
First is, to initiate process and requesting recovery code to be sent either to your email or phone. This could be done by calling ramenForgotStart method inside AuthControllerTrait trait. The function parameters are:
-
$requestwhich containing email or phone number, and -
$typewhich specify how the code should be sent.
Second is, verifying the code that has been sent to user. This could be done by calling ramenForgotCheck method. The function parameters are:
-
$requestwhich containing email or phone number where the code sent, and the user inputted code -
$typewhich specify how the code is sent.
Third is, answering security question and defining new password. This could be done by calling ramenForgotComplete method. The function parameters are:
-
$requestwhich containing user answer to the question, users new password, and also users email or phone number -
$typewhich specify how the code is sent.