Exemplo n.º 1
0
 /**
  * View user profile.
  * @return Response
  */
 public function index()
 {
     $user = Auth::user();
     $code = Google2FA::generateSecretKey();
     if ($user->has_two_factor_authentication || old('google_code')) {
         $code = old('google_code', $user->google2fa_secret);
     }
     $img = Google2FA::getQRCodeGoogleUrl('Deployer', $user->email, $code);
     return view('user.profile', ['google_2fa_url' => $img, 'google_2fa_code' => $code, 'title' => Lang::get('users.update_profile')]);
 }
Exemplo n.º 2
0
 /**
  * Updates the current user.
  *
  * @return \Illuminate\View\View
  */
 public function postUser()
 {
     $userData = array_filter(Binput::only(['username', 'email', 'password', 'google2fa']));
     $enable2FA = (bool) array_pull($userData, 'google2fa');
     // Let's enable/disable auth
     if ($enable2FA && !Auth::user()->hasTwoFactor) {
         $userData['google_2fa_secret'] = Google2FA::generateSecretKey();
     } elseif (!$enable2FA) {
         $userData['google_2fa_secret'] = '';
     }
     try {
         Auth::user()->update($userData);
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.user')->withInput($userData)->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::route('dashboard.user')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
 }
Exemplo n.º 3
0
 /**
  * Updates the current user.
  *
  * @return \Illuminate\View\View
  */
 public function postUser()
 {
     $items = Binput::all();
     $passwordChange = array_get($items, 'password');
     $enable2FA = (bool) array_pull($items, 'google2fa');
     // Let's enable/disable auth
     if ($enable2FA && !Auth::user()->hasTwoFactor) {
         $items['google_2fa_secret'] = Google2FA::generateSecretKey();
     } elseif (!$enable2FA) {
         $items['google_2fa_secret'] = '';
     }
     if (trim($passwordChange) === '') {
         unset($items['password']);
     }
     try {
         Auth::user()->update($items);
     } catch (ValidationException $e) {
         return Redirect::back()->withInput(Binput::except('password'))->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::back()->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success')));
 }
Exemplo n.º 4
0
 /**
  * Updates the current user.
  *
  * @return \Illuminate\View\View
  */
 public function postUser()
 {
     $items = Binput::all();
     $passwordChange = array_get($items, 'password');
     $enable2FA = (bool) array_pull($items, 'google2fa');
     // Let's enable/disable auth
     if ($enable2FA && !Auth::user()->hasTwoFactor) {
         $items['google_2fa_secret'] = Google2FA::generateSecretKey();
     } elseif (!$enable2FA) {
         $items['google_2fa_secret'] = '';
     }
     if (trim($passwordChange) === '') {
         unset($items['password']);
     }
     $user = Auth::user();
     $user->update($items);
     if (!$user->isValid()) {
         return Redirect::back()->withInput(Binput::except('password'))->with('title', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.edit.failure')))->with('errors', $user->getErrors());
     }
     $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.edit.success'));
     return Redirect::back()->with('success', $successMsg);
 }