Commit bba56b28 by 杨昕

修改后台用户登录

parent f8b03835
...@@ -48,17 +48,20 @@ class UsersController extends Controller ...@@ -48,17 +48,20 @@ class UsersController extends Controller
$user = DB::connection('mongodb') //选择使用mongodb $user = DB::connection('mongodb') //选择使用mongodb
->collection('users')->where('name',$username)->first(); ->collection('users')->where('name',$username)->first();
if (empty($user)){ if (empty($user)){
$data = [ $data = [
'name' => $username, 'name' => $username,
'password' => md5(123123), 'password' => md5(123123),
'organization_id' => 0, 'organization_id' => 0,
'status' => 0, 'status' => 0,
'create_time' => date('Y-m-d H:i:s',time()) 'create_time' => date('Y-m-d H:i:s',time()),
'user_type' => 1
]; ];
DB::connection("mongodb")->collection("users")->insertGetId($data); DB::connection("mongodb")->collection("users")->insertGetId($data);
$result = true; $result = true;
}else{ }else{
if ($user['password'] == md5($password)){ if ($user['password'] == md5($password)){
$result = true; $result = true;
}else{ }else{
...@@ -76,20 +79,19 @@ class UsersController extends Controller ...@@ -76,20 +79,19 @@ class UsersController extends Controller
200 200
); );
$result = json_decode($result,true); $result = json_decode($result,true);
if ($result['code']!=200){ if ($result['code']!=200){
$result = false; $result = false;
} }
} }
if ($result){ if ($result){
$data = [ $data = [
'name' => $username, 'name' => $username,
'password' => md5($password), 'password' => md5($password),
'organization_id' => 0, 'organization_id' => 0,
'status' => 0, 'status' => 0,
'create_time' => date('Y-m-d H:i:s',time()) 'create_time' => date('Y-m-d H:i:s',time()),
'user_type' => 0
]; ];
$user = DB::connection('mongodb') //选择使用mongodb $user = DB::connection('mongodb') //选择使用mongodb
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
namespace App\Http\Controllers\Web; namespace App\Http\Controllers\Web;
use App\Exceptions\ControllerException;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
...@@ -28,46 +29,42 @@ class LoginController extends Controller ...@@ -28,46 +29,42 @@ class LoginController extends Controller
{ {
if (request()->isMethod('post')) { if (request()->isMethod('post')) {
$url = "http://local.live.offcncloud.com/api/login";
$result = http_request_code($url,
['Content-Type'=>'application/x-www-form-urlencoded'],
'POST',
['username' => 'test3','password' => '123123'],
20
);
if ($result){ if (!$request->password) {
throw new ControllerException(400, '口令不能为空');
$res = json_decode($result,true); }
if (!$request->name) {
if ($res['data']){ throw new ControllerException(400, '昵称必须填写');
}
$params = $request->all();
$user = DB::connection('mongodb') //选择使用mongodb
->collection('users')->where('name',$request->name)->first();
if ($user){ $user = DB::connection('mongodb') //选择使用mongodb
Session::put("user",json_encode($user)); ->collection('users')->where('name',$request->name)->first();
return success($user);
}
$id = DB::connection("mongodb")->collection("users")->insertGetId($params); if ($user){
$id = ($id)->jsonSerialize();
$params['_id'] = $id['$oid'];
Session::put("user",json_encode($params));
return success($params);
if ($user['password'] == md5($request->password)){
$result = true;
}else{ }else{
$result = false;
}
if (!$result){
return error('用户验证失败'); return error('用户验证失败');
} }
}else{ $id = ($user['_id'])->jsonSerialize();
return error('用户验证失败'); $user['_id'] = $id['$oid'];
Session::put("user",json_encode($user));
return success($user);
} }
return error('用户验证失败');
} else { } else {
return view('admin.login'); return view('admin.login');
......
...@@ -236,10 +236,14 @@ class MemberController extends Controller ...@@ -236,10 +236,14 @@ class MemberController extends Controller
*/ */
public function disable(Request $request) public function disable(Request $request)
{ {
if (!$this->checkOwnHandle($request->id)) { if (!$this->checkOwnHandle($request->id)) {
throw new \App\Exceptions\FormException('你不能操作别人的'); throw new \App\Exceptions\FormException('你不能操作别人的');
} }
if ($request->id == $this->user['id']) {
var_dump($request->id);
var_dump(getAdmin()->_id);die;
if ($request->id == getAdmin()->_id) {
throw new \App\Exceptions\FormException('你不能操作你自己'); throw new \App\Exceptions\FormException('你不能操作你自己');
} }
UserModel::updateUserStatus($request); UserModel::updateUserStatus($request);
...@@ -320,13 +324,18 @@ class MemberController extends Controller ...@@ -320,13 +324,18 @@ class MemberController extends Controller
*/ */
public function checkOwnHandle($user_id) public function checkOwnHandle($user_id)
{ {
if ($this->user['name'] != config('custom.supper_admin.name')) {
$user = getAdmin();
if ($user->name != config('custom.supper_admin.name')) {
$result = UserModel::find($user_id); $result = UserModel::find($user_id);
if ($result === null) { if ($result === null) {
return false; return false;
} }
$user = Auth::user();
if ($user->roles[0]->slug!='admin') { if (!$user->user_type) {
return false; return false;
} }
} }
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
namespace App\Model; namespace App\Model;
use App\Exceptions\DatabaseException; use App\Exceptions\DatabaseException;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Jenssegers\Mongodb\Auth\User as Authenticatable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent; use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class UserModel extends Eloquent class UserModel extends Eloquent
...@@ -15,6 +13,10 @@ class UserModel extends Eloquent ...@@ -15,6 +13,10 @@ class UserModel extends Eloquent
*/ */
protected $collection = 'users'; protected $collection = 'users';
protected $connection = 'mongodb'; //使用mongodb
protected $primaryKey = '_id';
/* /*
* 获取用户列表 * 获取用户列表
*/ */
...@@ -57,11 +59,13 @@ class UserModel extends Eloquent ...@@ -57,11 +59,13 @@ class UserModel extends Eloquent
} }
public static function updateUserStatus(){ public static function updateUserStatus($request){
var_dump($request->all());die;
try{ try{
// $flag = DB::connection('mongodb')->collection("users")-> $flag = DB::connection('mongodb')->collection("users")->find();
}catch (\Exception $exception){ }catch (\Exception $exception){
......
...@@ -39,7 +39,7 @@ return [ ...@@ -39,7 +39,7 @@ return [
| |
*/ */
'debug' => env('APP_DEBUG', false), 'debug' => env('APP_DEBUG', true),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
......
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'supper_admin' => [
'name' => 'offcn',
],
];
...@@ -74,8 +74,8 @@ ...@@ -74,8 +74,8 @@
<span class="label ">已{{$STATUS[$user['status']]}}</span> <span class="label ">已{{$STATUS[$user['status']]}}</span>
</td> </td>
<td class="td-manage"> <td class="td-manage">
<a onclick="member_stop(this)" href="javascript:;" status="{{$user['status']}}"> <a onclick="member_stop(this,'{{$user["_id"]}}')" href="javascript:;" status="{{$user['status']}}">
<i class="iconfont">@if( $user['status'] == 1 )&#xe689;@else&#xe79e;@endif</i> <i class="iconfont">@if( $user['status'] == 1 ) &#xe79e;@else&#xe689;@endif</i>
</a> </a>
<a title="编辑" href="/web/member/{{$user['_id']}}/edit"> <a title="编辑" href="/web/member/{{$user['_id']}}/edit">
<i class="iconfont">&#xe609;</i> <i class="iconfont">&#xe609;</i>
...@@ -192,8 +192,6 @@ ...@@ -192,8 +192,6 @@
confirm: function () { confirm: function () {
if(title == '停用'){ if(title == '停用'){
//发异步把用户状态进行更改 //发异步把用户状态进行更改
opts.append('id',id); opts.append('id',id);
......
<!DOCTYPE html>
<html>
<head>
{{--@include('admin.common.header')--}}
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="x-body">
<div class="layui-tab-item layui-show">
<p style="text-align:center;"><img src="{{ asset('images/403.png') }}" width="400px;"></p>
</div>
<!-- <p style="color:#adabab;font-size:20px;margin-bottom:20px;text-align:center;">抱歉...你没有权限访问...</p> -->
<p style="text-align:center;"><a style="background-color: #DC143C;" href="/" class="layui-btn">返回首页</a></p>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
{{--@include('admin.common.header')--}}
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="x-body">
<div class="layui-tab-item layui-show">
<p style="text-align:center;"><img src="{{ asset('images/404.png') }}" width="400px;"></p>
</div>
<!-- <p style="color:#adabab;font-size:20px;margin-bottom:20px;text-align:center;">啊勒...你的页面跑到火星了...</p> -->
<p style="text-align:center;"><a style="background-color: #DC143C;" href="/" class="layui-btn">返回首页</a></p>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>中讯邮电咨询设计院有限公司</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--<meta name="csrf-token" content="PqQzIidZAVC5QjRd6AW6KsLh66so549ZLDtWCGlX">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="http://xiaoyu.enxtvadmin.com/css/font.css">
<link rel="stylesheet" href="http://xiaoyu.enxtvadmin.com/css/xadmin.css">
<script type="text/javascript" src="http://xiaoyu.enxtvadmin.com/js/jquery.min.js"></script>
<script src="http://xiaoyu.enxtvadmin.com/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="http://xiaoyu.enxtvadmin.com/js/xadmin.js"></script>-->
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="x-body">
<div class="layui-tab-item layui-show">
<p style="text-align:center;"><img src="http://xiaoyu.enxtvadmin.com/images/404.png" width="400px;"></p>
</div>
<!-- <p style="color:#adabab;font-size:20px;margin-bottom:20px;text-align:center;">啊勒...你的页面跑到火星了...</p> -->
<p style="text-align:center;"><a style="background-color: #DC143C;" href="/" class="layui-btn">返回首页</a></p>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>中讯邮电咨询设计院有限公司</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
</head>
<body>
<div class="x-body">
<div class="layui-tab-item layui-show">
<p style="text-align:center;"><img src="{{ asset('images/500.png') }}"></p>
</div>
</div>
</body>
</html>
\ 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