for_users → usr_users, and JWT shizzle.
このコミットが含まれているのは:
コミット
97229692a3
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
39
app/Http/Controllers/Auth/LoginController.php
ノーマルファイル
39
app/Http/Controllers/Auth/LoginController.php
ノーマルファイル
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
}
|
71
app/Http/Controllers/Auth/RegisterController.php
ノーマルファイル
71
app/Http/Controllers/Auth/RegisterController.php
ノーマルファイル
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'username' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:usr_users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'username' => $data['username'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
26
app/Http/Controllers/AuthController.php
ノーマルファイル
26
app/Http/Controllers/AuthController.php
ノーマルファイル
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Route;
|
||||
use App\Legislature;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Tymon\JWTAuth\Facades\JWTAuth;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
|
||||
class AuthController extends Controller {
|
||||
|
||||
public function authenticate(\Illuminate\Http\Request $request) {
|
||||
$credentials = $request->only('username', 'password'); // grab credentials from the request
|
||||
try {
|
||||
if (!$token = JWTAuth::attempt($credentials)) { // attempt to verify the credentials and create a token for the user
|
||||
return response()->json(['error' => 'invalid_credentials'], 401);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
return response()->json(['error' => 'could_not_create_token'], 500); // something went wrong whilst attempting to encode the token
|
||||
}
|
||||
|
||||
return response()->json(['token' => "Bearer $token"]);
|
||||
}
|
||||
}
|
||||
?>
|
@ -144,7 +144,10 @@ class BoardController extends Controller {
|
||||
|
||||
public function getUserPosts($top_id, $from, $to) { // /api/rpc/board/post/getuserposts/top/from/to
|
||||
return DB::table('for_posts')
|
||||
->join('for_users', 'for_posts.user_id', '=', 'for_users.id')
|
||||
->join('usr_users', 'for_posts.user_id', '=', 'usr_users.id')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'for_posts.user_id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'for_posts.user_id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'for_posts.user_id')
|
||||
->where('for_posts.top_id', $top_id)
|
||||
->offset($from)
|
||||
->limit($to)
|
||||
@ -152,7 +155,7 @@ class BoardController extends Controller {
|
||||
->get(array(
|
||||
"for_posts.id",
|
||||
"top_id",
|
||||
"user_id",
|
||||
"usr_users.id",
|
||||
"post_date",
|
||||
"message",
|
||||
"delete",
|
||||
@ -169,7 +172,7 @@ class BoardController extends Controller {
|
||||
"member_title",
|
||||
"gender",
|
||||
"avatar",
|
||||
"name_colour",
|
||||
"name_style",
|
||||
"display_name",
|
||||
"country"
|
||||
));
|
||||
@ -177,13 +180,16 @@ class BoardController extends Controller {
|
||||
|
||||
public function getUserPost($id) { // /api/rpc/board/post/getuserpost/id
|
||||
return DB::table('for_posts')
|
||||
->join('for_users', 'for_posts.user_id', '=', 'for_users.id')
|
||||
->join('usr_users', 'for_posts.user_id', '=', 'usr_users.id')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'for_posts.user_id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'for_posts.user_id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'for_posts.user_id')
|
||||
->where('for_posts.id', $id)
|
||||
->orderBy('for_posts.post_date', 'asc')
|
||||
->get(array(
|
||||
"for_posts.id",
|
||||
"top_id",
|
||||
"user_id",
|
||||
"usr_users.id",
|
||||
"post_date",
|
||||
"message",
|
||||
"delete",
|
||||
@ -200,7 +206,7 @@ class BoardController extends Controller {
|
||||
"member_title",
|
||||
"gender",
|
||||
"avatar",
|
||||
"name_colour",
|
||||
"name_style",
|
||||
"display_name",
|
||||
"country"
|
||||
));
|
||||
|
@ -177,11 +177,14 @@ class StoreController extends Controller {
|
||||
public function getEntry($id) { // /api/rpc/store/entry/getentry/id
|
||||
return DB::table('str_owners')
|
||||
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
|
||||
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
|
||||
->join('usr_users', 'str_owners.user_id', '=', 'usr_users.id')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'str_owners.user_id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'str_owners.user_id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'str_owners.user_id')
|
||||
->where('file_id', $id)
|
||||
->get(array(
|
||||
"file_id",
|
||||
"user_id",
|
||||
"usr_users.id",
|
||||
"cat_id",
|
||||
"title",
|
||||
"version",
|
||||
@ -196,7 +199,7 @@ class StoreController extends Controller {
|
||||
"perm_id",
|
||||
"gender",
|
||||
"display_name",
|
||||
"name_colour",
|
||||
"name_style",
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -14,45 +14,47 @@ use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
class UserController extends Controller {
|
||||
// User
|
||||
public function getUsers() { // /api/rpc/user/user/getusers
|
||||
return DB::table('for_users')
|
||||
return DB::table('usr_users')
|
||||
->select('*')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'usr_users.id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'usr_users.id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'usr_users.id')
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getUser($id) { // /api/rpc/user/user/getuser/id
|
||||
return DB::table('for_users')
|
||||
->select(
|
||||
'id',
|
||||
'username',
|
||||
'perm_id',
|
||||
'member_title',
|
||||
'reg_date',
|
||||
'website_address',
|
||||
'website_name',
|
||||
'gender',
|
||||
'location',
|
||||
'birthday',
|
||||
'bio',
|
||||
'avatar',
|
||||
'timezone',
|
||||
'strikes',
|
||||
'name_colour',
|
||||
'display_name',
|
||||
'yt_channel',
|
||||
'country',
|
||||
'curTZ', 'curDF', 'curTF', // Time and date stuff
|
||||
'usr_per_id', 'str_per_id', // Permission stuff.
|
||||
// TODO: hide the following stuff away from unprivileaged users.
|
||||
'email',
|
||||
'ip_address',
|
||||
'strikes'
|
||||
)
|
||||
return DB::table('usr_users')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'usr_users.id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'usr_users.id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'usr_users.id')
|
||||
->where('id', $id)
|
||||
->get();
|
||||
->get(array(
|
||||
"usr_users.id",
|
||||
'username',
|
||||
'perm_id',
|
||||
'member_title',
|
||||
'reg_date',
|
||||
'website_address',
|
||||
'website_name',
|
||||
'gender',
|
||||
'location',
|
||||
'birthday',
|
||||
'bio',
|
||||
'avatar',
|
||||
'strikes',
|
||||
'name_style',
|
||||
'display_name',
|
||||
'yt_channel',
|
||||
'country',
|
||||
// TODO: hide the following stuff away from unprivileaged users.
|
||||
'email',
|
||||
'ip_address',
|
||||
'strikes'
|
||||
));
|
||||
}
|
||||
|
||||
public function getPostStyle($id) { // /api/rpc/user/user/getpoststyle/id
|
||||
return DB:: table('for_users')
|
||||
return DB:: table('usr_users')
|
||||
->select('header', 'footer')
|
||||
->where('id', $id)
|
||||
->get();
|
||||
@ -76,8 +78,8 @@ class UserController extends Controller {
|
||||
}
|
||||
|
||||
public function login(Request $request) { // /api/rpc/user/auth/login
|
||||
$getUser = DB::table('for_users')
|
||||
->select('id', 'username', 'password', 'salt')
|
||||
$getUser = DB::table('usr_users')
|
||||
->select('id', 'username', 'password', 'remember_token')
|
||||
->where('username', $request->username)
|
||||
->get();
|
||||
|
||||
@ -93,15 +95,17 @@ class UserController extends Controller {
|
||||
if ($check_password === $getUser[0]->password) {
|
||||
$login_ok = true;
|
||||
|
||||
$credentials = $request->only('username', $check_password); // grab credentials from the request
|
||||
|
||||
$credentials = array(
|
||||
"username" => $request->username,
|
||||
"password" => $check_password
|
||||
);
|
||||
//dd($credentials);
|
||||
try {
|
||||
if (!$token = JWTAuth::attempt($credentials)) { // attempt to verify the credentials and create a token for the user
|
||||
if (!$token = JWTAuth::attempt($credentials)) {
|
||||
return response()->json(['error' => 'invalid_credentials'], 401);
|
||||
}
|
||||
}
|
||||
catch (JWTException $e) {
|
||||
return response()->json(['error' => 'could_not_create_token'], 500); // something went wrong whilst attempting to encode the token
|
||||
} catch (JWTException $e) {
|
||||
return response()->json(['error' => 'could_not_create_token'], 500);
|
||||
}
|
||||
|
||||
return response()->json(['token' => "Bearer $token"]);
|
||||
@ -147,10 +151,13 @@ class UserController extends Controller {
|
||||
public function getOwnersOfEntry($file_id) { // /api/rpc/user/owner/getownersofentry/id
|
||||
return DB::table('str_owners')
|
||||
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
|
||||
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
|
||||
->join('usr_users', 'str_owners.user_id', '=', 'usr_users.id')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'str_owners.user_id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'str_owners.user_id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'str_owners.user_id')
|
||||
->where('file_id', $file_id)
|
||||
->get(array(
|
||||
"user_id",
|
||||
"usr_users.id",
|
||||
"title",
|
||||
"version",
|
||||
"views",
|
||||
@ -162,7 +169,7 @@ class UserController extends Controller {
|
||||
"perm_id",
|
||||
"gender",
|
||||
"display_name",
|
||||
"name_colour",
|
||||
"name_style",
|
||||
));
|
||||
}
|
||||
|
||||
@ -176,10 +183,13 @@ class UserController extends Controller {
|
||||
public function getEntriesOfOwner($user_id) { // /api/rpc/user/owner/getentriesofowner/id
|
||||
return DB::table('str_owners')
|
||||
->join('str_file', 'str_owners.file_id', '=', 'str_file.id')
|
||||
->join('for_users', 'str_owners.user_id', '=', 'for_users.id')
|
||||
->join('usr_users', 'str_owners.user_id', '=', 'usr_users.id')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'str_owners.user_id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'str_owners.user_id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'str_owners.user_id')
|
||||
->where('user_id', $user_id)
|
||||
->get(array(
|
||||
"user_id",
|
||||
"usr_users.id",
|
||||
"title",
|
||||
"version",
|
||||
"views",
|
||||
@ -191,7 +201,7 @@ class UserController extends Controller {
|
||||
"perm_id",
|
||||
"gender",
|
||||
"display_name",
|
||||
"name_colour",
|
||||
"name_style",
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -39,28 +39,12 @@ use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
* @property int $ostatus
|
||||
* @property string $header
|
||||
* @property string $footer
|
||||
* @property string $theme
|
||||
* @property int $timezone
|
||||
* @property int $strikes
|
||||
* @property string $name_colour
|
||||
* @property int $permission_access
|
||||
* @property string $test_theme
|
||||
* @property int $theme_expire
|
||||
* @property string $display_name
|
||||
* @property string $yt_channel
|
||||
* @property string $country
|
||||
* @property string $video_css
|
||||
* @property string $curLanguage
|
||||
* @property string $curTheme
|
||||
* @property string $curTZ
|
||||
* @property string $curDF
|
||||
* @property string $curTF
|
||||
* @property int $curSBSize
|
||||
* @property int $coq
|
||||
* @property int $dev
|
||||
* @property int $fullsub
|
||||
* @property int $wikiadm
|
||||
* @property int $odbman
|
||||
* @property int $usr_per_id
|
||||
* @property int $blg_per_id
|
||||
* @property int $for_per_id
|
||||
@ -91,99 +75,75 @@ class ForUser extends Eloquent
|
||||
return [];
|
||||
}
|
||||
|
||||
public $timestamps = false;
|
||||
public $timestamps = false;
|
||||
|
||||
protected $casts = [
|
||||
'group' => 'int',
|
||||
'perm_id' => 'int',
|
||||
'permission_id' => 'int',
|
||||
'total_posts' => 'int',
|
||||
'total_threads' => 'int',
|
||||
'reg_date' => 'int',
|
||||
'last_post_date' => 'int',
|
||||
'last_post_location' => 'int',
|
||||
'gender' => 'int',
|
||||
'birthday' => 'int',
|
||||
'ontime' => 'int',
|
||||
'ostatus' => 'int',
|
||||
'timezone' => 'int',
|
||||
'strikes' => 'int',
|
||||
'permission_access' => 'int',
|
||||
'theme_expire' => 'int',
|
||||
'curSBSize' => 'int',
|
||||
'coq' => 'int',
|
||||
'dev' => 'int',
|
||||
'fullsub' => 'int',
|
||||
'wikiadm' => 'int',
|
||||
'odbman' => 'int',
|
||||
'usr_per_id' => 'int',
|
||||
'blg_per_id' => 'int',
|
||||
'for_per_id' => 'int',
|
||||
'sbx_per_id' => 'int',
|
||||
'str_per_id' => 'int',
|
||||
'doc_per_id' => 'int',
|
||||
'odb_per_id' => 'int'
|
||||
];
|
||||
protected $casts = [
|
||||
'group' => 'int',
|
||||
'perm_id' => 'int',
|
||||
'permission_id' => 'int',
|
||||
'total_posts' => 'int',
|
||||
'total_threads' => 'int',
|
||||
'reg_date' => 'int',
|
||||
'last_post_date' => 'int',
|
||||
'last_post_location' => 'int',
|
||||
'gender' => 'int',
|
||||
'birthday' => 'int',
|
||||
'ontime' => 'int',
|
||||
'ostatus' => 'int',
|
||||
'strikes' => 'int',
|
||||
'permission_access' => 'int',
|
||||
'usr_per_id' => 'int',
|
||||
'blg_per_id' => 'int',
|
||||
'for_per_id' => 'int',
|
||||
'sbx_per_id' => 'int',
|
||||
'str_per_id' => 'int',
|
||||
'doc_per_id' => 'int',
|
||||
'odb_per_id' => 'int'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'salt'
|
||||
];
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'salt'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'username',
|
||||
'password',
|
||||
'salt',
|
||||
'group',
|
||||
'perm_id',
|
||||
'member_title',
|
||||
'permission_id',
|
||||
'total_posts',
|
||||
'total_threads',
|
||||
'reg_date',
|
||||
'last_post_date',
|
||||
'last_post_location',
|
||||
'email',
|
||||
'website_address',
|
||||
'website_name',
|
||||
'gender',
|
||||
'location',
|
||||
'birthday',
|
||||
'bio',
|
||||
'ip_address',
|
||||
'avatar',
|
||||
'ontime',
|
||||
'ostatus',
|
||||
'header',
|
||||
'footer',
|
||||
'theme',
|
||||
'timezone',
|
||||
'strikes',
|
||||
'name_colour',
|
||||
'permission_access',
|
||||
'test_theme',
|
||||
'theme_expire',
|
||||
'display_name',
|
||||
'yt_channel',
|
||||
'country',
|
||||
'video_css',
|
||||
'curLanguage',
|
||||
'curTheme',
|
||||
'curTZ',
|
||||
'curDF',
|
||||
'curTF',
|
||||
'curSBSize',
|
||||
'coq',
|
||||
'dev',
|
||||
'fullsub',
|
||||
'wikiadm',
|
||||
'odbman',
|
||||
'usr_per_id',
|
||||
'blg_per_id',
|
||||
'for_per_id',
|
||||
'sbx_per_id',
|
||||
'str_per_id',
|
||||
'doc_per_id',
|
||||
'odb_per_id'
|
||||
];
|
||||
protected $fillable = [
|
||||
'username',
|
||||
'password',
|
||||
'salt',
|
||||
'group',
|
||||
'perm_id',
|
||||
'member_title',
|
||||
'permission_id',
|
||||
'total_posts',
|
||||
'total_threads',
|
||||
'reg_date',
|
||||
'last_post_date',
|
||||
'last_post_location',
|
||||
'email',
|
||||
'website_address',
|
||||
'website_name',
|
||||
'gender',
|
||||
'location',
|
||||
'birthday',
|
||||
'bio',
|
||||
'ip_address',
|
||||
'avatar',
|
||||
'ontime',
|
||||
'ostatus',
|
||||
'header',
|
||||
'footer',
|
||||
'strikes',
|
||||
'name_colour',
|
||||
'permission_access',
|
||||
'display_name',
|
||||
'yt_channel',
|
||||
'country',
|
||||
'usr_per_id',
|
||||
'blg_per_id',
|
||||
'for_per_id',
|
||||
'sbx_per_id',
|
||||
'str_per_id',
|
||||
'doc_per_id',
|
||||
'odb_per_id'
|
||||
];
|
||||
}
|
||||
|
48
app/User.php
ノーマルファイル
48
app/User.php
ノーマルファイル
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
class User extends Authenticatable implements JWTSubject {
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'username', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the identifier that will be stored in the subject claim of the JWT.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJWTIdentifier() {
|
||||
return $this->getKey(); // Eloquent Model method
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a key value array, containing any custom claims to be added to the JWT.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJWTCustomClaims() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
?>
|
@ -15,7 +15,7 @@ return [
|
||||
|
||||
'defaults' => [
|
||||
'guard' => 'web',
|
||||
'passwords' => 'users',
|
||||
'passwords' => 'usr_users',
|
||||
],
|
||||
|
||||
/*
|
||||
@ -38,12 +38,12 @@ return [
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
'provider' => 'usr_users',
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'driver' => 'token',
|
||||
'provider' => 'users',
|
||||
'driver' => 'jwt',
|
||||
'provider' => 'usr_users',
|
||||
],
|
||||
],
|
||||
|
||||
@ -65,14 +65,14 @@ return [
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'usr_users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => App\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'usr_users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// 'table' => 'usr_users',
|
||||
// ],
|
||||
],
|
||||
|
||||
@ -92,8 +92,8 @@ return [
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'usr_users' => [
|
||||
'provider' => 'usr_users',
|
||||
'table' => 'password_resets',
|
||||
'expire' => 60,
|
||||
],
|
||||
|
@ -144,7 +144,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'jwt' => 'Tymon\JWTAuth\Providers\JWT\NamshiAdapter',
|
||||
'jwt' => 'Tymon\JWTAuth\Providers\JWT\Namshi',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -155,7 +155,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter',
|
||||
'auth' => 'Tymon\JWTAuth\Providers\Auth\Illuminate',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -166,7 +166,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter',
|
||||
'storage' => 'Tymon\JWTAuth\Providers\Storage\Illuminate',
|
||||
|
||||
],
|
||||
|
||||
|
@ -15,7 +15,7 @@ use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\User::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'username' => $faker->name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
|
||||
'remember_token' => str_random(10),
|
||||
|
@ -13,9 +13,9 @@ class CreateUsersTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
Schema::create('usr_users', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
$table->string('username');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
@ -30,6 +30,6 @@ class CreateUsersTable extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('usr_users');
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
// Auth
|
||||
Route::post('/api/rpc/user/auth/isauth', 'UserController@isAuth');
|
||||
Route::post('/api/rpc/user/auth/login', 'UserController@login');
|
||||
//Route::post('/api/rpc/user/auth/login', 'UserController@login');
|
||||
Route::post('/api/rpc/user/auth/login', 'AuthController@authenticate');
|
||||
Route::post('/api/rpc/user/auth/register', 'UserController@register');
|
||||
Route::post('/api/rpc/user/auth/logout', 'UserController@logout');
|
||||
Route::group(['middleware' => 'jwt'], function () {
|
||||
|
82
yb2db.sql
ノーマルファイル
82
yb2db.sql
ノーマルファイル
@ -0,0 +1,82 @@
|
||||
--
|
||||
-- Tables
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `usr_users` (
|
||||
`id` int(10) NOT NULL,
|
||||
`username` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
||||
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
||||
`password` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
||||
`remember_token` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||
`created_at` timestamp NULL DEFAULT NULL,
|
||||
`updated_at` timestamp NULL DEFAULT NULL
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `usr_details` (
|
||||
`user_id` int(10) NOT NULL,
|
||||
`total_posts` int(10) NOT NULL,
|
||||
`total_threads` int(10) NOT NULL,
|
||||
`reg_date` int(10) NOT NULL,
|
||||
`last_post_date` int(10) NOT NULL,
|
||||
`last_post_location` int(10) NOT NULL,
|
||||
`ontime` int(10) NOT NULL,
|
||||
`strikes` int(1) NOT NULL
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `usr_profile` (
|
||||
`user_id` int(10) NOT NULL,
|
||||
`gender` int(1) NOT NULL,
|
||||
`member_title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`website_address` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`website_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`location` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`birthday` int(10) NOT NULL,
|
||||
`bio` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`ip_address` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`avatar` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`ostatus` int(1) NOT NULL DEFAULT 1,
|
||||
`header` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`footer` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`post_style` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`signature` text COLLATE utf8_unicode_ci NOT NULL,
|
||||
`name_style` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`display_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`yt_channel` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`country` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`date_format` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
|
||||
`isClock24` int(1) NOT NULL DEFAULT 1,
|
||||
`isShowSeconds` int(1) NOT NULL,
|
||||
`isShowTimezone` int(1) NOT NULL
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `usr_perm_id` (
|
||||
`user_id` int(10) NOT NULL,
|
||||
`perm_id` int(10) NOT NULL,
|
||||
`usr_per_id` int(10) NOT NULL DEFAULT 4,
|
||||
`blg_per_id` int(10) NOT NULL DEFAULT 4,
|
||||
`for_per_id` int(10) NOT NULL DEFAULT 4,
|
||||
`sbx_per_id` int(10) NOT NULL DEFAULT 4,
|
||||
`str_per_id` int(10) NOT NULL DEFAULT 4,
|
||||
`doc_per_id` int(10) NOT NULL DEFAULT 4,
|
||||
`odb_per_id` int(10) NOT NULL DEFAULT 4
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
||||
--
|
||||
-- Data
|
||||
--
|
||||
INSERT INTO `usr_users` SELECT `id`, `username`, `email`, `password`, NULL, NULL, NULL FROM `for_users`;
|
||||
INSERT INTO `usr_details` SELECT `id`, `total_posts`, `total_threads`, `reg_date`, `last_post_date`, `last_post_location`, `ontime`, `strikes` FROM `for_users`;
|
||||
INSERT INTO `usr_profile` SELECT `id`, `gender`, `member_title`, `website_address`, `website_name`, `location`, `birthday`, `bio`, `ip_address`, `avatar`, `ostatus`, `header`, `footer`, NULL, NULL, `name_colour`, `display_name`, `yt_channel`, `country`, `curDF`, NULL, NULL, NULL FROM `for_users`;
|
||||
INSERT INTO `usr_perm_id` SELECT `id`, `perm_id`, `usr_per_id`, `blg_per_id`, `for_per_id`, `sbx_per_id`, `str_per_id`, `doc_per_id`, `odb_per_id` FROM `for_users`;
|
||||
|
||||
--
|
||||
-- Indexes
|
||||
--
|
||||
ALTER TABLE `usr_users`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `email` (`email`);
|
||||
ALTER TABLE `usr_details`
|
||||
ADD PRIMARY KEY (`user_id`);
|
||||
ALTER TABLE `usr_profile`
|
||||
ADD PRIMARY KEY (`user_id`);
|
||||
ALTER TABLE `usr_perm_id`
|
||||
ADD PRIMARY KEY (`user_id`);
|
新しいイシューから参照
ユーザーをブロックする