Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-09-05 12:29:47 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
6b6f6d2c9207b0a04e67434d526233bc3c059e4f
6b6f6d2c
1 parent
eac7378c
Cleaned up some unessasary facade usage
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
11 deletions
app/Http/Controllers/Controller.php
app/Http/Controllers/UserController.php
app/Http/routes.php
app/Services/SocialAuthService.php
app/Http/Controllers/Controller.php
View file @
6b6f6d2
...
...
@@ -30,16 +30,16 @@ abstract class Controller extends BaseController
public
function
__construct
()
{
// Get a user instance for the current user
$user
=
Auth
::
user
();
$user
=
auth
()
->
user
();
if
(
!
$user
)
{
$user
=
User
::
getDefault
();
}
// Share variables with views
view
()
->
share
(
'signedIn'
,
Auth
::
check
());
view
()
->
share
(
'signedIn'
,
auth
()
->
check
());
view
()
->
share
(
'currentUser'
,
$user
);
// Share variables with controllers
$this
->
currentUser
=
$user
;
$this
->
signedIn
=
Auth
::
check
();
$this
->
signedIn
=
auth
()
->
check
();
}
/**
...
...
app/Http/Controllers/UserController.php
View file @
6b6f6d2
...
...
@@ -64,7 +64,7 @@ class UserController extends Controller
]);
$user
=
$this
->
user
->
fill
(
$request
->
all
());
$user
->
password
=
Hash
::
make
(
$request
->
get
(
'password'
));
$user
->
password
=
bcrypt
(
$request
->
get
(
'password'
));
$user
->
save
();
$user
->
attachRoleId
(
$request
->
get
(
'role'
));
...
...
@@ -120,7 +120,7 @@ class UserController extends Controller
if
(
$request
->
has
(
'password'
)
&&
$request
->
get
(
'password'
)
!=
''
)
{
//dd('cat');
$password
=
$request
->
get
(
'password'
);
$user
->
password
=
Hash
::
make
(
$password
);
$user
->
password
=
bcrypt
(
$password
);
}
$user
->
save
();
return
redirect
(
'/users'
);
...
...
app/Http/routes.php
View file @
6b6f6d2
...
...
@@ -43,6 +43,7 @@ Route::group(['middleware' => 'auth'], function () {
});
// Uploads
Route
::
post
(
'/upload/image'
,
'ImageController@upload'
);
// Users
...
...
@@ -75,7 +76,6 @@ Route::group(['middleware' => 'auth'], function () {
Route
::
get
(
'/settings'
,
'SettingController@index'
);
Route
::
post
(
'/settings'
,
'SettingController@update'
);
});
// Login using social authentication
...
...
app/Services/SocialAuthService.php
View file @
6b6f6d2
...
...
@@ -60,8 +60,8 @@ class SocialAuthService
// Get any attached social accounts or users
$socialAccount
=
$this
->
socialAccount
->
where
(
'driver_id'
,
'='
,
$socialId
)
->
first
();
$user
=
$this
->
userRepo
->
getByEmail
(
$socialUser
->
getEmail
());
$isLoggedIn
=
\Auth
::
check
();
$currentUser
=
\Auth
::
user
();
$isLoggedIn
=
auth
()
->
check
();
$currentUser
=
auth
()
->
user
();
// When a user is not logged in but a matching SocialAccount exists,
// Log the user found on the SocialAccount into the application.
...
...
@@ -115,7 +115,7 @@ class SocialAuthService
private
function
logUserIn
(
$user
)
{
\Auth
::
login
(
$user
);
auth
()
->
login
(
$user
);
return
redirect
(
'/'
);
}
...
...
@@ -183,9 +183,10 @@ class SocialAuthService
*/
public
function
detachSocialAccount
(
$socialDriver
)
{
\Auth
::
user
()
->
socialAccounts
()
->
where
(
'driver'
,
'='
,
$socialDriver
)
->
delete
();
session
();
auth
()
->
user
()
->
socialAccounts
()
->
where
(
'driver'
,
'='
,
$socialDriver
)
->
delete
();
\Session
::
flash
(
'success'
,
$socialDriver
.
' account successfully detached'
);
return
redirect
(
\Auth
::
user
()
->
getEditUrl
());
return
redirect
(
auth
()
->
user
()
->
getEditUrl
());
}
}
\ No newline at end of file
...
...
Please
register
or
sign in
to post a comment