yii2-user

how to insert data to 2 tables i.e Employee and User(migrated) from single form(Employee Create) and controller in yii2

不羁岁月 提交于 2019-12-25 18:17:21
问题 this is my create page questions/create.php ` <?= $form->field($model, 'clinic_id')->dropDownList( ArrayHelper::map(Clinic::find()->all(),'id','clinic_name'), ['prompt'=> 'Select Clinic'] )?> <?= $form->field($model, 'first_name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'last_name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'user_name')->textInput(['maxlength' => true]) ?> <?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?> <

Custom userIdentity class in yii2

南楼画角 提交于 2019-12-25 04:43:34
问题 I want to create custom userIdentity class according to my specific requirements .Here the code is <?php namespace app\models; use yii\web\IdentityInterface; use app\models\dbTables\Users; class UserIdentity implements IdentityInterface{ const ERROR_USERNAME_INVALID=3; const ERROR_PASSWORD_INVALID=4; const ERROR_NONE=0; public $errorCode; private $_id; private $_email; private $_role; private $_name; public function findIdentityById($id){ $objUserMdl = new Users; $user = $objUserMdl::findOne(

Yii2 Override find() to add default condition globally

眉间皱痕 提交于 2019-12-21 19:44:37
问题 I have to override the method using namespace common\models; use Yii; use yii\db\ActiveQuery; class Addfindcondition extends ActiveQuery { public function init() { $this->andOnCondition([$this->modelClass::tableName() . '.branch_id' => Yii::$app->user->identity->branch_id ]); parent::init(); } } And call the method in each model separately like this public static function find() { return new Addfindcondition(get_called_class()); } Now I want to override the find method globally. How it is

yii2, google outh2 and scope

本小妞迷上赌 提交于 2019-12-19 02:15:32
问题 I am using Yii2, GoogleOAuth and yii2-user extension. I want to receive user google circles and set scope to my config: 'authClientCollection' => [ 'class' => 'yii\authclient\Collection', 'clients' => [ 'google' => [ 'class' => 'yii\authclient\clients\GoogleOAuth', 'clientId' => '758709912345-p4qp4lqihit5un1u6qb75msqp5m5j6d8.apps.googleusercontent.com', 'clientSecret' => 'ZygOIi1-0asfktUQ1pKOFOo', 'scope' => 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo

Get User Profile - dektrium/yii2-user Yii2

前提是你 提交于 2019-12-12 15:10:11
问题 I have used dektrium/yii2-user in my application. And there is a method named getID() in User.php of vendor/dektrium and this method can be accessed by Yii::$app->user->getID() and returns id of the logged in user. However, there is another method named getProfile() whose function is to return complete profile details of currently logged in user. But, this method is giving 500-internal server error. exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\web\User

How to set separate homeUrl for authenticated users and guests in yii2

我与影子孤独终老i 提交于 2019-12-12 03:49:48
问题 I'm wondering is it possible to make different homeUrl for authenticated and guest users? I have such rules in SiteController.php public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'only' => ['logout', 'signup'], 'rules' => [ [ 'actions' => ['signup'], 'allow' => true, 'roles' => ['?'], 'denyCallback' => function() { return $this->redirect('/account'); } ], [ 'actions' => ['logout', 'condition'], 'allow' => true, 'roles' => ['@'], ], ], ], 'verbs' => [

Yii2-user: How to create admin user in batch mode?

寵の児 提交于 2019-12-08 10:31:45
问题 When deploying my application there is of course always an admin user. How can I create such an admin user as a first user without any interaction ... ... by means of SQL? ... using a Yii2-migration? 回答1: Found it. There is an easy way to do this with Yii2 builtin migrations. In Yii2-user there are some hooks we can use to create users. This code has to be inserted in a migration. after creating a new migration ./yii migrate/create , preferably after creating initial tables in the database:

Yii2 REST API BasicAuth not working

只愿长相守 提交于 2019-12-06 13:51:45
问题 Im implementing REST API Authentication module as following step 1. Create user by Admin 2. First tim: login by Basic Auth to return access_token 3. Use access_token at step 2 to Auth user by. QueryParamAuth as this instruction it work with QueryParamAuth https://github.com/yiisoft/yii2/blob/master/docs/guide/rest-authentication.md But it not work at step2. Auth by BasicAuth I debug it. $this->auth always return null. Although $username and $password right class HttpBasicAuth extends

How to login using two different model or switch identity class in yii2?

亡梦爱人 提交于 2019-12-06 02:36:58
问题 I want to allow user login from two different model. Config.php 'user' => [ 'identityClass' => 'app\models\User', //one more class here 'enableAutoLogin' => false, 'authTimeout' => 3600*2, ], LoginForm.php public function rules() { return [ // username and password are both required [['username', 'password'], 'required'], // rememberMe must be a boolean value ['rememberMe', 'boolean'], // password is validated by validatePassword() ['password', 'validatePassword'], ]; } public function

How to customize vendor view files?

♀尐吖头ヾ 提交于 2019-12-06 02:25:51
问题 In yii2 how do I customize vendor view files without modifying the original view files? I'm using dektrium yii2-user and would like to make a few changes to the login page. 回答1: You can assign your view path for dektrium yii2-user in this way (assume @app your app alias) : 'components' => [ 'view' => [ 'theme' => [ 'pathMap' => [ '@dektrium/user/views' => '@app/views/your_dir_views' // mapping for override the views dektrium with your views ], ], ..... ], 来源: https://stackoverflow.com