Commit 8ac488e5 authored by shajiaiming's avatar shajiaiming

同步用户接口

parent 1e858c3a
<?php
namespace api\controllers;
use common\models\Admin;
use Yii;
use api\base\BaseController;
class UserController extends BaseController
{
/**
* 用户同步
*/
public function actionUserSync()
{
$header = Yii::$app->request->headers;
$platform_id = $header['platform_id'] ?? 17;
$post = Yii::$app->request->post();
$data = [
'bind_uid' => $post['bind_uid'],
'username' => $post['username'],
'salt' => Yii::$app->security->generateRandomString(),
'password' => Yii::$app->security->generatePasswordHash('123456'),
'reg_time' => time(),
'reg_ip' => ip2long('127.0.0.1'),
'last_login_time' => 0,
'last_login_ip' => ip2long('127.0.0.1'),
'update_time' => 0,
'status' => 1,
'platform_id' => $platform_id
];
// $password = Yii::$app->security->generatePasswordHash('123456');
// $salt = Yii::$app->security->generateRandomString();
// $reg_time = time();
// $reg_ip = ip2long('127.0.0.1');
// $last_login_time = 0;
// $last_login_ip = ip2long('127.0.0.1');
// $update_time = 0;
// $status = 1;
// $additional = [$password, $salt, $reg_time, $reg_ip, $last_login_time, $last_login_ip, $update_time, $status];
$role = Yii::$app->request->post('role', 'GHPwallet');
$model = new Admin();
if($model->load($data, '') && $model->save()) {
$auth = Yii::$app->authManager;
$role = $auth->getRole($role);
$auth->assign($role, $model->uid);
exit;
} else {
var_dump($model->errors);exit;
}
}
/**
* 用户注册
*/
public function actionCreate()
{
}
/**
* 重置密码
*/
public function actionResetPassword()
{
}
/**
* 获取用户基本信息
* @return array
*/
public function actionView()
{
}
/*
* 更改密码
* @return array
*/
public function actionUpdatePassword()
{
}
}
\ No newline at end of file
...@@ -19,6 +19,7 @@ use yii\web\IdentityInterface; ...@@ -19,6 +19,7 @@ use yii\web\IdentityInterface;
* @property string $last_login_ip * @property string $last_login_ip
* @property string $update_time * @property string $update_time
* @property integer $status * @property integer $status
* @property integer $platform_id
*/ */
class Admin extends \common\modelsgii\Admin implements IdentityInterface class Admin extends \common\modelsgii\Admin implements IdentityInterface
{ {
......
...@@ -17,6 +17,7 @@ use yii\helpers\HtmlPurifier; ...@@ -17,6 +17,7 @@ use yii\helpers\HtmlPurifier;
* @property string $last_login_ip * @property string $last_login_ip
* @property string $update_time * @property string $update_time
* @property integer $status * @property integer $status
* @property integer $platform_id
*/ */
class Admin extends \common\core\BaseActiveRecord class Admin extends \common\core\BaseActiveRecord
{ {
...@@ -42,7 +43,7 @@ class Admin extends \common\core\BaseActiveRecord ...@@ -42,7 +43,7 @@ class Admin extends \common\core\BaseActiveRecord
return HtmlPurifier::process($str); return HtmlPurifier::process($str);
} }
], ],
[['reg_time', 'reg_ip', 'last_login_time', 'last_login_ip', 'update_time', 'status'], 'integer'], [['reg_time', 'reg_ip', 'last_login_time', 'last_login_ip', 'update_time', 'status', 'platform_id'], 'integer'],
[['username'], 'string', 'max' => 32], [['username'], 'string', 'max' => 32],
[['password'], 'string', 'min' => 6, 'max' => 60], [['password'], 'string', 'min' => 6, 'max' => 60],
[['salt'], 'string', 'max' => 32], [['salt'], 'string', 'max' => 32],
...@@ -65,6 +66,7 @@ class Admin extends \common\core\BaseActiveRecord ...@@ -65,6 +66,7 @@ class Admin extends \common\core\BaseActiveRecord
'last_login_ip' => 'Last Login Ip', 'last_login_ip' => 'Last Login Ip',
'update_time' => 'Update Time', 'update_time' => 'Update Time',
'status' => 'Status', 'status' => 'Status',
'platform_id' => 'platform_id',
'group' => 'group' 'group' => 'group'
]; ];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment