Commit 095af285 authored by shajiaiming's avatar shajiaiming

分离接口

parent e8a4b09a
......@@ -18,20 +18,21 @@ class UserController extends BaseController
*/
public function actionLogin()
{
$msg = 'ok';
$code = 0;
$model = new LoginForm();
$model->setScenario(LoginForm::SCENARIOS_LOGIN);
$model->load(Yii::$app->request->post(),'');
if ($model->login()) {
$response = [
'access_token' => $model->login(),
];
} else {
$error = implode(", ", \yii\helpers\ArrayHelper::getColumn($model->errors, 0, false)); // Model's Errors string
$response = [
'msg' => $error
];
if(!$model->login()){
$msg = implode(", ", \yii\helpers\ArrayHelper::getColumn($model->errors, 0, false)); // Model's Errors string
$data = null;
$code = -1;
goto doEnd;
}
return $response;
$data = ['access_token' => $model->login()];
doEnd :
return ['code' => $code, 'msg' => $msg, 'data' => $data];
}
/**
......
......@@ -19,87 +19,6 @@ class WalletController extends BaseController
{
$platforms = CoinPlatform::find()->asArray()->all();
return $platforms;
}
/**
* 用户同步
*/
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()
{
return ['code' => 0, 'msg' => 'ok', 'data' => $platforms];
}
}
\ No newline at end of file
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