v0.1.5 Add the first support for create user account
This commit is contained in:
parent
d0e2900941
commit
b0fd4d4320
|
@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Model as Eloquent;
|
|||
class User extends Eloquent{
|
||||
|
||||
protected $fillable = [
|
||||
'name','password','remember_token'
|
||||
'name','password','remember_token' , 'permission'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
|
|
|
@ -4,15 +4,15 @@ require "../../bootstrap.php";
|
|||
|
||||
use Backend\Model\Post;
|
||||
|
||||
if(isset($_POST['title'])){
|
||||
//Create a new initialize
|
||||
$post = new Post();
|
||||
if(isset($_SESSION['permission'])){
|
||||
$user = new Post();
|
||||
$user->name = $_POST['name'];
|
||||
$hashPass = password_hash($_POST['password'], PASSWORD_DEFAULT);
|
||||
$user->password = $hashPass;
|
||||
|
||||
//Get the data from post and save it to the post model
|
||||
$post->title = $_POST['title'];
|
||||
$post->description = $_POST['description'];
|
||||
|
||||
//Call the save function.
|
||||
if($post->save())
|
||||
echo $post->id;
|
||||
if(!$user->save()){
|
||||
echo "Error";
|
||||
}else{
|
||||
echo "saved";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ if (isset($_POST['loginsubmit'])) {
|
|||
if ($password->save()) {
|
||||
$_SESSION['token'] = $token;
|
||||
$_SESSION['name'] = $username;
|
||||
if($user->permission === 1){
|
||||
$_SESSION['permission'] = $token;
|
||||
}
|
||||
header('location: ../../Frontend/admin.php?login=success');
|
||||
exit();
|
||||
http_response_code(200);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "../../bootstrap.php";
|
||||
$createUser = User::Create(['name' => "Victor", 'password' => password_hash('1234', PASSWORD_DEFAULT)]);
|
||||
use Backend\Model\User;
|
||||
$createUser = User::Create(['name' => "admin", 'password' => password_hash('aA123456&', PASSWORD_DEFAULT), 'permission' => 0]);
|
||||
echo "User was created";
|
||||
|
|
|
@ -6,6 +6,7 @@ use Illuminate\Database\Capsule\Manager as Capsule;
|
|||
Capsule::schema()->create('users', function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->integer('permission');
|
||||
$table->longtext('password');
|
||||
$table->longtext('remember_token');
|
||||
$table->timestamps();
|
||||
|
|
Loading…
Reference in New Issue