/** * Construct a form. * * @param null $route * @param array $options * @return string */ public static function open($route = null, $options = []) { $opts = self::evalOptions($options); $route = $route == null ? $_SERVER['REQUEST_URI'] : $route; $method = preg_match('/method\\=/i', $opts) ? "" : "method='POST' "; return "<form action='{$route}' {$method}{$opts} accept-charset='UTF-8'>\n\n <input type='hidden' name='__FORM_TOKEN__' value='" . Token::create() . "'>"; }
/** * Execute the Process * * @todo execute * @param $callback * @return mixed */ public function execute($callback = "") { $request = new LoginRequest($_POST); if ($request->validate()) { $attempt = User::where('username', $request->get('username'))->where('password', Hash::encode($request->get('password')))->where('active', 'yes'); if ($attempt->exists()) { $user = $attempt->first(); $user->remember_token = Token::create(); $user->save(); $_SESSION['user'] = $user(); return Route::redirect('welcome'); } else { Session::setFlash('flash', 'username/password is incorrect.<br><br>'); return $callback(); } } else { return $callback(); } }