Skip to content

Commit

Permalink
Merge pull request #407 from chrispappas/update-confide
Browse files Browse the repository at this point in the history
Update Confide to 4.x. This is great! Merging today. Thanks @chrispappas
  • Loading branch information
andrewelkins committed Dec 23, 2014
2 parents 326b1bc + f3c6317 commit 57a7a4a
Show file tree
Hide file tree
Showing 14 changed files with 444 additions and 221 deletions.
4 changes: 2 additions & 2 deletions app/config/app.php
Expand Up @@ -110,7 +110,7 @@
'Illuminate\Workbench\WorkbenchServiceProvider',

/* Additional Providers */
'Zizaco\Confide\ConfideServiceProvider', // Confide Provider
'Zizaco\Confide\ServiceProvider', // Confide Provider
'Zizaco\Entrust\EntrustServiceProvider', // Entrust Provider for roles
'Bllim\Datatables\DatatablesServiceProvider', // Datatables

Expand Down Expand Up @@ -186,7 +186,7 @@
'View' => 'Illuminate\Support\Facades\View',

/* Additional Aliases */
'Confide' => 'Zizaco\Confide\ConfideFacade', // Confide Alias
'Confide' => 'Zizaco\Confide\Facade', // Confide Alias
'Entrust' => 'Zizaco\Entrust\EntrustFacade', // Entrust Alias
'String' => 'Andrew13\Helpers\String', // String
'Carbon' => 'Carbon\Carbon', // Carbon
Expand Down
12 changes: 6 additions & 6 deletions app/config/packages/zizaco/confide/config.php
Expand Up @@ -47,10 +47,10 @@
|
|
*/
'login_form' => 'confide::login',
'signup_form' => 'confide::signup',
'forgot_password_form' => 'confide::forgot_password',
'reset_password_form' => 'confide::reset_password',
'login_form' => 'site.partials.user.login',
'signup_form' => 'site.partials.user.signup',
'forgot_password_form' => 'site.partials.user.forgot_password',
'reset_password_form' => 'site.partials.user.reset_password',

/*
|--------------------------------------------------------------------------
Expand All @@ -70,8 +70,8 @@
|
*/

'email_reset_password' => 'confide::emails.passwordreset', // with $user and $token.
'email_account_confirmation' => 'confide::emails.confirm', // with $user
'email_reset_password' => 'emails.auth.passwordreset', // with $user and $token.
'email_account_confirmation' => 'emails.auth.confirm', // with $user

/*
|--------------------------------------------------------------------------
Expand Down
96 changes: 52 additions & 44 deletions app/controllers/admin/AdminUsersController.php
Expand Up @@ -96,24 +96,44 @@ public function postCreate()
// before saving. This field will be used in Ardent's
// auto validation.
$this->user->password_confirmation = Input::get( 'password_confirmation' );
$this->user->confirmed = Input::get( 'confirm' );

// Generate a random confirmation code
$this->user->confirmation_code = md5(uniqid(mt_rand(), true));

if (Input::get('confirm')) {
$this->user->confirmed = Input::get('confirm');
}

// Permissions are currently tied to roles. Can't do this yet.
//$user->permissions = $user->roles()->preparePermissionsForSave(Input::get( 'permissions' ));

// Save if valid. Password field will be hashed before save
$this->user->save();

if ( $this->user->id )
{
if ( $this->user->id ) {
// Save roles. Handles updating.
$this->user->saveRoles(Input::get( 'roles' ));

if (Config::get('confide::signup_email')) {
$user = $this->user;
Mail::queueOn(
Config::get('confide::email_queue'),
Config::get('confide::email_account_confirmation'),
compact('user'),
function ($message) use ($user) {
$message
->to($user->email, $user->username)
->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
}
);
}

// Redirect to the new user page
return Redirect::to('admin/users/' . $this->user->id . '/edit')->with('success', Lang::get('admin/users/messages.create.success'));
}
else
{
return Redirect::to('admin/users/' . $this->user->id . '/edit')
->with('success', Lang::get('admin/users/messages.create.success'));

} else {

// Get validation errors (see Ardent package)
$error = $this->user->errors()->all();

Expand Down Expand Up @@ -163,54 +183,42 @@ public function getEdit($user)
/**
* Update the specified resource in storage.
*
* @param $user
* @param User $user
* @return Response
*/
public function postEdit($user)
{
// Validate the inputs
$validator = Validator::make(Input::all(), $user->getUpdateRules());


if ($validator->passes())
{
$oldUser = clone $user;
$user->username = Input::get( 'username' );
$user->email = Input::get( 'email' );
$user->confirmed = Input::get( 'confirm' );

$password = Input::get( 'password' );
$passwordConfirmation = Input::get( 'password_confirmation' );

if(!empty($password)) {
if($password === $passwordConfirmation) {
$user->password = $password;
// The password confirmation will be removed from model
// before saving. This field will be used in Ardent's
// auto validation.
$user->password_confirmation = $passwordConfirmation;
} else {
// Redirect to the new user page
return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.password_does_not_match'));
}
$oldUser = clone $user;
$user->username = Input::get( 'username' );
$user->email = Input::get( 'email' );
$user->confirmed = Input::get( 'confirm' );

$password = Input::get( 'password' );
$passwordConfirmation = Input::get( 'password_confirmation' );

if(!empty($password)) {
if($password === $passwordConfirmation) {
$user->password = $password;
// The password confirmation will be removed from model
// before saving. This field will be used in Ardent's
// auto validation.
$user->password_confirmation = $passwordConfirmation;
} else {
unset($user->password);
unset($user->password_confirmation);
// Redirect to the new user page
return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.password_does_not_match'));
}
}

if($user->confirmed == null) {
$user->confirmed = $oldUser->confirmed;
}

$user->prepareRules($oldUser, $user);

// Save if valid. Password field will be hashed before save
$user->amend();
if($user->confirmed == null) {
$user->confirmed = $oldUser->confirmed;
}

if ($user->save()) {
// Save roles. Handles updating.
$user->saveRoles(Input::get( 'roles' ));
} else {
return Redirect::to('admin/users/' . $user->id . '/edit')->with('error', Lang::get('admin/users/messages.edit.error'));
return Redirect::to('admin/users/' . $user->id . '/edit')
->with('error', Lang::get('admin/users/messages.edit.error'));
}

// Get validation errors (see Ardent package)
Expand Down

0 comments on commit 57a7a4a

Please sign in to comment.