public function doLogIn() { $errorText = 'The username or password you entered does not match our records.'; $input = Input::all(); $uname = $input['uname']; $pword = $input['pword']; $u = User::where('username', $uname)->get(); if ($u == null) { Session::flash('error', $errorText); return redirect()->route('ct_admin_login'); } $u = $u[0]; if (Hash::check($pword, $u->password)) { //success! Session::put('user', $u->id); Artisan::call('view:clear'); return redirect()->route('ct_admin_dashboard'); } else { Session::flash('error', $errorText); return redirect()->route('ct_admin_login'); } }
/** * * Plugin Helper Functions * * The functions below here are intended to make it easier for programmers to extend the Cmstwo framework. * They provide easy and secure access to the models, without exposing the model classes themselves. * */ public static function getUser($id = null, $name = null) { if ($id == null && $name == null) { if (Session::has('user')) { $id = Session::get('user'); $user = User::find($id); } else { return false; } } if ($id != null) { $user = User::find($id); } else { $user = User::where('username', $name)->first(); } $out = new \stdClass(); $out->name = $user->name; $out->email = $user->email; $out->data = $user->data; $out->type = $user->userType->name; $out->perms = $user->userType->permissions; return $out; }