示例#1
0
 public function actionPost()
 {
     $data = $this->getData('user');
     if (!isset($data['username'])) {
         throw new BadRequest("USERNAME_REQUIRED");
     }
     if (!isset($data['password'])) {
         throw new BadRequest("PASSWORD_REQUIRED");
     }
     $username = $data['username'];
     $md5Password = md5($data['password']);
     $user = User::model($this->getManager()->getComponent('db'));
     $where = "`username`='{$username}' AND `password`='{$md5Password}'";
     $userinfo = $user->where($where)->find();
     if ($userinfo != null) {
         session_start();
         $roleId = $userinfo['role_id'];
         $role = Role::model($this->getManager()->getComponent('db'));
         $roleinfo = $role->where("`id`={$userinfo['role_id']}")->find();
         $_SESSION['userid'] = $userinfo['id'];
         $_SESSION['username'] = $userinfo['username'];
         $_SESSION['authtype'] = $userinfo['authtype'];
         $_SESSION['userrole'] = $roleinfo['name'];
         $_SESSION['permission'] = Json::toArray($roleinfo['permission']);
         return array('result' => array('success' => true, 'key' => base64_encode($username . ',' . $md5Password . ',' . session_id())));
     } else {
         throw new BadRequest('USERNAME_PASSWORD_INCORRECT');
     }
 }
示例#2
0
文件: Role.php 项目: annasoal/newsite
 public function __construct()
 {
     parent::__construct();
     $this->priv = MPriv::app();
     $this->role = MRole::app();
     $this->check_access('edit_rights');
 }
示例#3
0
文件: User.php 项目: annasoal/newsite
 public function __construct()
 {
     parent::__construct();
     $this->user = MUser::app();
     $this->image = Image::app();
     $this->role = MRole::app();
     $this->check_access('edit_users');
 }
示例#4
0
文件: user.php 项目: yeaha/lysine
 protected function getRoleName()
 {
     return Role::find($this->role_id)->name;
 }
示例#5
0
 public function index()
 {
     $list = Role::orderBy('sort', 'asc')->get();
     return view($this->templatePath() . '.index', array('role_list' => $list));
 }