1
This commit is contained in:
@@ -35,6 +35,7 @@ class User extends Controller
|
||||
protected $user_to_special_obj = '';
|
||||
protected $user_index_obj = '';
|
||||
protected $user_email_index_obj = '';
|
||||
protected $user_register_check_obj = '';
|
||||
|
||||
public function __construct(\think\Request $request = null)
|
||||
{
|
||||
@@ -57,6 +58,7 @@ class User extends Controller
|
||||
$this->user_to_special_obj = Db::name('user_to_special');
|
||||
$this->user_index_obj = Db::name('user_index');
|
||||
$this->user_email_index_obj = Db::name('user_email_index');
|
||||
$this->user_register_check_obj = Db::name('user_register_check');
|
||||
}
|
||||
|
||||
public function pstest(){
|
||||
@@ -103,6 +105,10 @@ class User extends Controller
|
||||
if ($user_info == null) { //登陆失败
|
||||
return json(['code' => 1]);
|
||||
}
|
||||
|
||||
if($user_info['register_check']==0){
|
||||
return jsonError('Please click on the link sent to your email inbox to complete your registration.');
|
||||
}
|
||||
//黑名单验证
|
||||
$blackCheck = $this->user_black_obj->where('user_id', $user_info['user_id'])->where('black_state', 0)->find();
|
||||
if ($blackCheck) {
|
||||
@@ -113,6 +119,7 @@ class User extends Controller
|
||||
$this->user_obj->where('user_id = ' . $user_info['user_id'])->update($up_data);
|
||||
$roles = $this->getUserRoles($user_info['account']);
|
||||
|
||||
|
||||
$re['roles'] = $roles;
|
||||
$re['userinfo'] = $user_info;
|
||||
return jsonSuccess($re);
|
||||
@@ -698,6 +705,9 @@ class User extends Controller
|
||||
return json('errcaptcha');
|
||||
}
|
||||
|
||||
$code = get_str();
|
||||
|
||||
Db::startTrans();
|
||||
//存入数据
|
||||
$inser_data['account'] = trim($account);
|
||||
$inser_data['password'] = md5($data['password']);
|
||||
@@ -706,27 +716,52 @@ class User extends Controller
|
||||
$inser_data['realname'] = $data['name'];
|
||||
$inser_data['ctime'] = time();
|
||||
$id = $this->user_obj->insertGetId($inser_data);
|
||||
|
||||
//存储注册验证信息
|
||||
$insert_check['user_id'] = $id;
|
||||
$insert_check['code'] = $code;
|
||||
$insert_check['ctime'] = time();
|
||||
$i_res = $this->user_register_check_obj->insert($insert_check);
|
||||
|
||||
//发送注册成功邮件
|
||||
$tt = 'Hello,<br><br>';
|
||||
$tt .= 'Your account has been created. You may check on the status of your manuscript using this submission and tracking system: https://submission.tmrjournals.com<br>';
|
||||
$tt .= "Username:$account<br>";
|
||||
$tt .= "Password:" . $data['password'] . '<br><br>';
|
||||
$tt .= "Many thanks<br>TMR Publishing Group";
|
||||
sendEmail($email, 'Dear ' . $data['name'], 'TMR', $tt);
|
||||
$sendUser = [
|
||||
'title' => 'Dear ' . $data['name'], // 邮件标题
|
||||
'content' => $tt, //邮件内容
|
||||
'user_id' => $id, //收件人ID
|
||||
'email' => $email, // 收件人邮箱
|
||||
'journal_id' => 0, // 期刊ID
|
||||
'sendEmail' => Env::get('email.send_email'), // 期刊邮箱
|
||||
'sendPassword' => Env::get('email.send_email_password'), // 期刊密码
|
||||
'from_name' => 'TMR'
|
||||
];
|
||||
// Queue::push('app\api\job\domail@fire',$sendUser,'domail');
|
||||
return json($inser_data);
|
||||
$tt = "Hello,<br><br>";
|
||||
$tt .= "To protect the email relationship unobstructed. <br><br>";
|
||||
$tt .= "Please verify your email address to complete the account registration:<br><br>";
|
||||
$tt .= "<a href='https://submission.tmrjournals.com/login?code=".$code."'>https://submission.tmrjournals.com/login?code=".$code."</a><br><br>";
|
||||
$tt .= "Thank you.<br>TMR Publishing Group<br>https://www.tmrjournals.com";
|
||||
|
||||
if($id&&$i_res){
|
||||
Db::commit();
|
||||
sendEmail($email, 'Dear ' . $data['name'], 'TMR', $tt);
|
||||
return jsonSuccess([]);
|
||||
}else{
|
||||
Db::rollback();
|
||||
return jsonError("system error");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核注册验证码
|
||||
*/
|
||||
public function checkRegisterCode(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'code'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonSuccess($rule->getError());
|
||||
}
|
||||
$check_info = $this->user_register_check_obj->where('code',$data['code'])->where('state',0)->find();
|
||||
if(!$check_info){
|
||||
return jsonError('not find this code');
|
||||
}
|
||||
$this->user_obj->where('user_id',$check_info['user_id'])->update(['register_check'=>1]);
|
||||
$this->user_register_check_obj->where('user_rc_id',$check_info['user_rc_id'])->update(['state'=>1]);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取验证码图片(用户注册)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user