Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
CO-OP Search
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kittisak Maneewong
CO-OP Search
Commits
94d8b219
Commit
94d8b219
authored
Apr 08, 2019
by
Kittisak Maneewong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit auth
parent
c13e2d48
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
4 deletions
+33
-4
AuthController.php
app/Http/Controllers/AuthController.php
+25
-2
User.php
app/User.php
+1
-1
2014_10_12_000000_create_users_table.php
database/migrations/2014_10_12_000000_create_users_table.php
+7
-1
No files found.
app/Http/Controllers/AuthController.php
View file @
94d8b219
...
...
@@ -18,9 +18,10 @@ class AuthController extends Controller
{
public
function
register
(
Request
$request
)
{
if
(
$request
->
json
()
->
get
(
'role'
)
==
1
)
{
$validator
=
Validator
::
make
(
$request
->
json
()
->
all
()
,
[
'name'
=>
'required|string|max:255'
,
'email'
=>
'required|string|email|max:255|unique:
users'
,
'email'
=>
'required|string|email|max:255|unique:users,email_
users'
,
'password'
=>
'required|string|min:8|confirmed'
,
]);
...
...
@@ -30,9 +31,31 @@ class AuthController extends Controller
$user
=
User
::
create
([
'name'
=>
$request
->
json
()
->
get
(
'name'
),
'email'
=>
$request
->
json
()
->
get
(
'email'
),
'password'
=>
Hash
::
make
(
$request
->
json
()
->
get
(
'password'
)),
'email_users'
=>
$request
->
json
()
->
get
(
'email'
),
]);
}
else
{
$validator
=
Validator
::
make
(
$request
->
json
()
->
all
()
,
[
'company_name'
=>
'required|string|max:255'
,
'username'
=>
'required|string|max:255|unique:users'
,
'email'
=>
'required|string|email|max:255|unique:users,email_employers'
,
'password'
=>
'required|string|min:8|confirmed'
,
'tel'
=>
'required|string|max:255'
,
]);
if
(
$validator
->
fails
())
{
return
response
()
->
json
(
$validator
->
errors
()
->
toJson
(),
400
);
}
$user
=
User
::
create
([
'company_name'
=>
$request
->
json
()
->
get
(
'company_name'
),
'password'
=>
Hash
::
make
(
$request
->
json
()
->
get
(
'password'
)),
'username'
=>
$request
->
json
()
->
get
(
'username'
),
'tel'
=>
$request
->
json
()
->
get
(
'tel'
),
'role'
=>
2
,
'email_employers'
=>
$request
->
json
()
->
get
(
'email'
),
]);
}
$token
=
JWTAuth
::
fromUser
(
$user
);
...
...
app/User.php
View file @
94d8b219
...
...
@@ -17,7 +17,7 @@ class User extends Authenticatable implements JWTSubject
* @var array
*/
protected
$fillable
=
[
'name'
,
'
email'
,
'password'
,
'name'
,
'
password'
,
'username'
,
'company_name'
,
'tel'
,
'email_users'
,
'email_employers'
,
'role'
];
/**
...
...
database/migrations/2014_10_12_000000_create_users_table.php
View file @
94d8b219
...
...
@@ -15,9 +15,15 @@ class CreateUsersTable extends Migration
{
Schema
::
create
(
'users'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
string
(
'email'
,
100
)
->
unique
();
$table
->
integer
(
'role'
)
->
default
(
1
);
$table
->
string
(
'name'
)
->
nullable
();
$table
->
timestamp
(
'email_verified_at'
)
->
nullable
();
$table
->
string
(
'password'
);
$table
->
string
(
'username'
)
->
nullable
();
$table
->
string
(
'company_name'
)
->
nullable
();
$table
->
string
(
'tel'
)
->
nullable
();
$table
->
string
(
'email_users'
)
->
nullable
();
$table
->
string
(
'email_employers'
)
->
nullable
();
$table
->
rememberToken
();
$table
->
timestamps
();
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment