I want to implement  user registration/login process in my project in which i have web client application made in angular and mobile client is on android.
I am using REST for client/server communication. I have installed yii2-user in my yii developed back-end. What I want is  to create a rest api in  such a way that each of my client application use yii2-user for user registration and login process. So that in client if user want to register  the request will be handled by yii-2 user module? Any suggestion that how can I achieve this?
Or is there any better way to make REST api for  registration and authentication in Yii2?
Use the yii2-user controller e.g dektrium "UserController" and extend it from \yii\rest\ActiveController then you can specify the model class in the UserController as
public $modelClass = 'dektrium\user\models\User';
In the rest post request use some parameter to give json response for rest request. i.e
register-form[username]=YOURUSERNAME®ister-form[password]=YOURPASS®ister-form[email][email protected]&someparam=true
In the controller
$model->load(\Yii::$app->request->post()) && $model->register()
will successfully register the user.
You can extend the idea from here. cheers :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With