Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui #1

Open
wants to merge 10 commits into
base: hxt
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

476 changes: 392 additions & 84 deletions .idea/workspace.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public function __construct()
public function postLogin(){
$name = $_GET['username'];
$password = $_GET['password'];
//$remember = $_GET['remember'];
$remember = $_GET['remember'];
$data = array('name'=>$name,'password'=>$password);

if (\Auth::attempt($data)){
if (\Auth::attempt($data,$remember)){
$privilege = \DB::table('users')
->where('name', '=',$name)
->pluck('privilege');
Expand Down
99 changes: 61 additions & 38 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,73 @@
| and give it the controller to call when that URI is requested.
|
*/
//Route::group(['middleware'=>'auth'], function(){//中间件,拦截,用于身份验证

Route::get('/', function () {
return view('login');
});
Route::get('/', function () {
return view('index');
});

Route::get('/test', function () {
return view('test');
});
Route::get('/test', function () {
return view('test');
});

Route::get('/register', function () {
return view('auth.register');
});

Route::get('/home', function () {
return view('home');
});

/*
* 数据库方面的操作
*/

//注册用户
Route::get('/db/addUser', function() {
$name=$_GET['username'];
$password=$_GET['password'];
$privilege='user';
$id = DB::table('users')
->insertGetId(
array(
'name' => $name,
'password' => Hash::make($password),
'privilege' => $privilege
)
);
return $id;
});


/*
* 数据库方面的操作
*/

//注册用户
Route::get('/db/addUser', function() {
$name=$_GET['username'];
$email=$_GET['email'];
$privilege=$_GET['privilege'];
$password=$_GET['password'];
$id = DB::table('users')
->insertGetId(
//查看是否有用户存在
Route::get('/db/checkUser', function() {
$name = $_GET['username'];
$result = DB::table('users')->where('name','=',$name)->first();
if ($result != NULL){
return 0;
}else return 1;
});


//登录验证密码
Route::get('/db/checkPwd', function() {
$name=$_SESSION['editPwdUserName'];
$inputPwd = $_GET['inputPwd'];

if (\Auth::validate(
array(
'name' => $name,
'email' => $email,
'privilege' => $privilege,
'password' => Hash::make($password)
)
);
});
//登录验证密码
Route::get('/db/checkPwd', function() {
$name=$_SESSION['editPwdUserName'];
$inputPwd = $_GET['inputPwd'];

if (\Auth::validate(
array(
'name'=>$name,
'password'=>$inputPwd))){
return 1;//登录成功
}else{
return 0;//登录失败
}
});
'name'=>$name,
'password'=>$inputPwd))){
return 1;//登录成功
}else{
return 0;//登录失败
}
});

//});


/*
* 身份验证方面的操作
Expand Down
10 changes: 8 additions & 2 deletions database/migrations/2014_10_12_000000_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('name')->unique();
$table->string('privilege');
$table->string('email')->unique();
$table->string('email');
$table->string('password');
$table->rememberToken();
$table->timestamps();
Expand Down Expand Up @@ -53,6 +53,12 @@ public function up()
'privilege' => 'user',
'email' => '[email protected]',
'password' => Hash::make('123')
),
array(
'name' => 'hxt',
'privilege' => 'user',
'email' => '[email protected]',
'password' => Hash::make('123')
)
)
);
Expand Down
Loading