Example #1
0
 public function register()
 {
     //系统维护检测
     service('user')->checkSystemClose();
     if (IS_POST) {
         Validate::make([['code', 'captcha', '验证码输入错误', 1], ['password', 'confirm:password2', '两次密码输入不一致', 3]]);
         //默认用户组
         $User = new User();
         $User['username'] = Request::post('username');
         //用户组过期时间
         $daylimit = Db::table('user_group')->where('id', v('config.register.groupid'))->pluck('daylimit');
         $User['endtime'] = time() + $daylimit * 3600 * 24;
         //获取密码与加密密钥
         $info = $User->getPasswordAndSecurity();
         $User['password'] = $info['password'];
         $User['security'] = $info['security'];
         $User['email'] = Request::post('email');
         $User['qq'] = Request::post('qq');
         $User['mobile'] = Request::post('mobile');
         $User['groupid'] = v('config.register.groupid');
         $User['status'] = v('config.register.audit');
         if (!$User->save()) {
             message($User->getError(), 'back', 'error');
         }
         message('注册成功,请登录系统', u('login', ['from' => $_GET['from']]));
     }
     return view();
 }