public static function createUser($user_fp, $input, $timestamp = false) { $timestamp = $timestamp ? $timestamp : date('Y-m-d H:i:s'); $pub_hash = BaseController::randString(8) . strtolower(substr($user_fp, -8)); $priv_hash = BaseController::randString(32); $clear_info = BaseController::isSigned(trim($input['info'])); $user = new User(); $user->public_hash = $pub_hash; $user->private_hash = password_hash($priv_hash, PASSWORD_BCRYPT); $user->pgp = trim($input['key']); $user->user_fp = $user_fp; $user->info = $input['info'] ? $input['info'] : ""; $user->clear_info = $clear_info ? $clear_info : ""; $user->active_session = ""; $user->timestamp = $timestamp; $user->save(); return ['priv_hash' => $priv_hash, 'user' => $user]; }
public function createApiKey() { self::validator(['comment' => 'max:60']); $user = User::find(self::userId()); // Check number of issued keys (max 3) if (Apikey::where('user_id', '=', self::userId())->count() > 2) { App::abort(500, 'Maximum 3 API keys'); } $key = new Apikey(); $key->api_key = BaseController::randString(32); $key->user_id = self::userId(); $key->user_fp = self::userFp(); $key->comment = Input::get('comment', ''); if (Input::get('readonly')) { $key->readonly = 1; } $key->save(); return Redirect::to('settings/api_keys'); }
| Application & Route Filters |-------------------------------------------------------------------------- | | Below you will find the "before" and "after" events for the application | which may be used to do any work before or after a request into your | application. Here you may also register your custom route filters. | */ App::before(function () { if (!Request::is('api/*')) { session_start(); if (in_array(BaseController::cookieGet('lang'), ['en', 'ru', 'by'])) { App::setLocale(BaseController::cookieGet('lang')); } if (!BaseController::sessionGet('token')) { BaseController::sessionSet('token', BaseController::randString(6)); } } }); App::after(function () { }); /* * Registration captcha check */ Route::filter('signup', function () { if (!BaseController::checkCaptcha()) { return View::make('verif.signup'); } }); /* * Retrieving URL captcha check