Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0ede36c7
authored
Dec 18, 2019
by
Jonathan Reinink
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve demo user check to not rely on primary key
1 parent
57e7d3ba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
app/Http/Controllers/UsersController.php
app/User.php
app/Http/Controllers/UsersController.php
View file @
0ede36c
...
@@ -79,8 +79,8 @@ class UsersController extends Controller
...
@@ -79,8 +79,8 @@ class UsersController extends Controller
public
function
update
(
User
$user
)
public
function
update
(
User
$user
)
{
{
if
(
App
::
environment
(
'demo'
)
&&
$user
->
id
===
1
)
{
return
Redirect
::
route
(
'users.edit'
,
$user
)
->
with
(
'error'
,
'Updating the demo user is not allowed.'
);
return
Redirect
::
route
(
'users.edit'
,
$user
)
->
with
(
'error'
,
'Updating the demo user is not allowed.'
);
if
(
App
::
environment
(
'demo'
)
&&
$user
->
isDemoUser
())
{
}
}
Request
::
validate
([
Request
::
validate
([
...
@@ -107,8 +107,8 @@ class UsersController extends Controller
...
@@ -107,8 +107,8 @@ class UsersController extends Controller
public
function
destroy
(
User
$user
)
public
function
destroy
(
User
$user
)
{
{
if
(
App
::
environment
(
'demo'
)
&&
$user
->
id
===
1
)
{
return
Redirect
::
route
(
'users.edit'
,
$user
)
->
with
(
'error'
,
'Deleting the demo user is not allowed.'
);
return
Redirect
::
route
(
'users.edit'
,
$user
)
->
with
(
'error'
,
'Deleting the demo user is not allowed.'
);
if
(
App
::
environment
(
'demo'
)
&&
$user
->
isDemoUser
())
{
}
}
$user
->
delete
();
$user
->
delete
();
...
...
app/User.php
View file @
0ede36c
...
@@ -42,6 +42,11 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
...
@@ -42,6 +42,11 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
}
}
}
public
function
isDemoUser
()
{
return
$user
->
email
===
'johndoe@example.com'
;
}
public
function
scopeOrderByName
(
$query
)
public
function
scopeOrderByName
(
$query
)
{
{
$query
->
orderBy
(
'last_name'
)
->
orderBy
(
'first_name'
);
$query
->
orderBy
(
'last_name'
)
->
orderBy
(
'first_name'
);
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment