Cachet/src/Http/Controllers/DashUserController.php

60 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace CachetHQ\Cachet\Http\Controllers;
2015-01-01 15:45:04 +00:00
2015-01-03 17:51:35 +00:00
use CachetHQ\Cachet\Models\User;
2015-01-02 12:05:50 +00:00
use GrahamCampbell\Binput\Facades\Binput;
2015-01-01 16:18:24 +00:00
use Illuminate\Routing\Controller;
2015-01-01 15:45:04 +00:00
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use PragmaRX\Google2FA\Vendor\Laravel\Facade as Google2FA;
2015-01-01 15:45:04 +00:00
class DashUserController extends Controller
{
/**
* Shows the user view.
2014-12-29 23:07:46 +00:00
*
* @return \Illuminate\View\View
*/
public function showUser()
{
2015-01-01 10:39:22 +00:00
return View::make('dashboard.user.index')->with([
'pageTitle' => trans('dashboard.team.profile').' - '.trans('dashboard.dashboard'),
]);
}
/**
2014-12-21 10:19:18 +00:00
* Updates the current user.
2014-12-29 23:07:46 +00:00
*
* @return \Illuminate\View\View
*/
public function postUser()
{
2015-01-02 12:05:50 +00:00
$items = Binput::all();
$enable2FA = (bool) array_pull($items, 'google2fa');
// Let's enable/disable auth
$authSecret = $enable2FA && ! Auth::user()->hasEnabled2FA ? Google2FA::generateSecretKey() : '';
$items['google_2fa_secret'] = $authSecret;
$updated = Auth::user()->update($items);
return Redirect::back()->with('updated', $updated);
}
2015-01-03 17:51:35 +00:00
/**
* Regenerates the users API key.
*
* @return \Illuminate\View\View
*/
public function regenerateApiKey(User $user)
{
$user->api_key = User::generateApiKey();
$user->save();
return Redirect::back();
}
}