function Check_User_Cart() { $Identifier = ''; if (!Sentry::check()) { return false; } else { $Identifier = Sentry::user()->id; if (Cookie::has('Anon_Cart_Extension')) { $AnonIdentifier = Cookie::get('Anon_Cart_Extension'); $dataAnon = Cache::get('user_cart.' . $AnonIdentifier); if (Cache::has('user_cart.' . $Identifier)) { $dataUser = Cache::get('user_cart.' . $Identifier); if ($dataAnon != null && $dataUser != null) { foreach ($dataAnon as $key => $value) { if (!isset($dataUser[$key])) { $dataUser[$key] = $value; } } Cache::forever('user_cart.' . $Identifier, $dataUser); Cache::forget('user_cart.' . $AnonIdentifier); } } else { if ($dataAnon != null) { Cache::forever('user_cart.' . $Identifier, $dataAnon); Cache::forget('user_cart.' . $AnonIdentifier); } } } } }
public function run() { DB::table('users')->delete(); DB::table('groups')->delete(); DB::table('users_groups')->delete(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'admin', 'last_name' => 'admin', 'activated' => 1)); Sentry::getGroupProvider()->create(array('name' => 'Super Admin', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Office Admin', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Project Manager', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Team Leader', 'permissions' => array('admin' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Developer', 'permissions' => array('admin' => 1))); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "admin", 'first_name' => 'Ashok', 'last_name' => 'Adhikari', 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "santosh", 'first_name' => 'Santosh', 'last_name' => 'Dhungana', 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "dinesh", 'first_name' => 'Dinesh', 'last_name' => 'Sharma', 'activated' => 1)); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => "asheem", 'first_name' => 'Asheem', 'last_name' => 'Manandhar', 'activated' => 1)); // Assign user permissions $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Super Admin'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Office Admin'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Project Manager'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Team Leader'); $adminUser->addGroup($adminGroup); $adminUser = Sentry::getUserProvider()->findByLogin('*****@*****.**'); $adminGroup = Sentry::getGroupProvider()->findByName('Developer'); $adminUser->addGroup($adminGroup); }
public function assessmentupdateget($dash, $id) { $assessment = Assessments::find($id); $user = User::find($assessment->teacherid); if (Sentry::getUser()->id == $user->id) { $theme = Theme::uses('dashboard')->layout('default'); $view = array('name' => 'Dashboard Assessment Update', 'id' => $id); $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Assessments', 'url' => Setting::get('system.dashurl') . '/assessments'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/assessment/' . $id]]); $theme->appendTitle(' - Assessment Update'); $theme->asset()->container('datatable')->writeScript('inline-script', '$(document).ready(function(){ $(\'#attachments\').dataTable({ "sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>", "oLanguage": { "sLengthMenu": "_MENU_ ' . ' Attachments per page" }, "sPagination":"bootstrap" }); });$(document).ready(function(){ $(\'#questionfail\').dataTable({ "sDom": "<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'l><\'col-xs-5 col-sm-5 col-md-5\'f>r>t<\'row\'<\'col-xs-5 col-sm-5 col-md-5\'i><\'col-xs-5 col-sm-5 col-md-5\'p>>", "oLanguage": { "sLengthMenu": "_MENU_ ' . ' Failures per page" }, "sPagination":"bootstrap" }); });'); $theme->asset()->container('footer')->writeScript('inline-script', '$(document).ready(function(){ $("#examsheader").hide(); $("div#exams").hide(); $("div#examslock").hide(); $(".hidequestions").hide(); $(".hidequestions").click(function(){ $("div#exams").hide(2000); $(\'html, body\').animate({ scrollTop: $("#top").offset().top }, 2000); $("#examsheader").hide(1200); $("#examslock").hide(1200); $(".hidequestions").hide(1000); $("#showquestions").show(1000); }); $("#showquestions").click(function(){ $("div#exams").show(2000); $("div#examslock").show(100); $(\'html, body\').animate({ scrollTop: $("#examslock").offset().top }, 2000); $("#examsheader").show(1000); $(".hidequestions").show(1000); $("#showquestions").hide(1000); }); });'); return $theme->scope('assessment.update', $view)->render(); // return View::make('dashboard.assessments.update')->with('id',$id); } else { return "UPDATE NOT AUTHORISED"; } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('groups')->delete(); Sentry::getGroupProvider()->create(array('name' => 'Users', 'permissions' => array('admin.users' => 0, 'user.interface' => 1))); Sentry::getGroupProvider()->create(array('name' => 'Admins', 'permissions' => array('admin.users' => 1, 'user.interface' => 1))); Sentry::getGroupProvider()->create(array('name' => 'EmfUsers', 'permissions' => array('admin.users' => 0, 'user.interface' => 1, 'emf.login' => 1))); }
public static function canEdit($id) { if (Sentry::check() && (Sentry::getUser()->id == $id || Sentry::getUser()->isSuperUser())) { return true; } return false; }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('groups')->delete(); Sentry::getGroupProvider()->create(array('name' => 'Users')); Sentry::getGroupProvider()->create(array('name' => 'Admins')); Sentry::getGroupProvider()->create(array('name' => 'Subscribers')); }
protected function insert_users() { for ($i = 0; $i != 20; ++$i) { $password = $this->get_random(self::$RANDOM_ALPHA_NUM, 6, 16); Sentry::createUser(['password' => $password, 'nickname' => $this->get_random(self::$RANDOM_ALPHA, 4, 12), 'real_name' => $this->get_random(self::$RANDOM_ALPHA, 4, 12), 'phone' => rand(0, count(self::$TELEPHONE_PREFIX)) + $this->get_random(self::$RANDOM_NUM, 8, 8), 'account' => $this->get_random(self::$RANDOM_ALPHA_NUM, 6, 16), 'role' => 1, 'gender' => rand(0, 1), 'activated' => 1]); } }
public function getProdlist() { $user = Sentry::getUser()->id; // $content = View::make('backend.widgets.prodlist'); // return View::make('backend.general', compact('content')); return View::make('backend.widgets.prodlist'); }
public function pushMessage() { if (!Sentry::check()) { return Response::json(array('errCode' => 10, 'message' => '请登录')); } Sentry::login(Sentry::findUserById(5), false); $user = Sentry::getUser(); // $user = User::find(1); $push_status = PushStatus::where('user_id', $user->id)->first(); if (count($push_status) == 0) { $push_status = new PushStatus(); $push_status->user_id = $user->id; $push_status->status = 1; if (!$push_status->save()) { return Response::json(array('errCode' => 1, 'message' => '[数据库错误]开启消息推送失败')); } return Response::json(array('errCode' => 0, 'message' => '开启消息推送')); } if ($push_status->status == 1) { $push_status->status = 0; if (!$push_status->save()) { return Response::json(array('errCode' => 2, 'message' => '[数据库错误]开启消息推送失败')); } return Response::json(array('errCode' => 0, 'message' => '开启消息推送')); } if ($push_status->status == 0) { $push_status->status = 1; if (!$push_status->save()) { return Response::json(array('errCode' => 3, 'message' => '[数据库错误]开启消息推送失败')); } return Response::json(array('errCode' => 0, 'message' => '开启消息推送')); } }
public function update_post($id) { $this->_exists($id); $rules = User::get_rules($id); $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { // Find the user using the user id $user = Sentry::findUserById($id); $user->first_name = Input::get('first_name'); $user->last_name = Input::get('last_name'); $user->tin_number = Input::get('tin_number'); $user->landline = Input::get('landline'); $user->mobile = Input::get('mobile'); $user->work_address = json_endcode(explode(",", Input::get('work_address'))); $user->home_address = json_endcode(explode(",", Input::get('home_address'))); $user->company = Input::get('company'); $user->occupation = Input::get('occupation'); $user->email = Input::get('email'); if (Input::get('password')) { $user->password = Input::get('password'); } if (Input::get('activated') == 1) { $user->activated = true; } else { $user->activated = false; } $user->save(); return Redirect::to('admin/clients')->with('success', 'Client account has been successfully updated.'); } return Redirect::to('admin/clients/update/' . $id)->withErrors($validator)->withInput(); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (\Sentry::check()) { return new RedirectResponse(url('/')); } return $next($request); }
public function postRegistro() { $input = Input::all(); $reglas = array('nombre' => 'required', 'apellido' => 'required', 'celular' => 'required|numeric|unique:users', 'cedula' => 'required|numeric|unique:users', 'email' => 'required|email|unique:users', 'pin' => 'required|numeric|digits_between:0,4', 'password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required|min:6'); $validation = Validator::make($input, $reglas); if ($validation->fails()) { return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]); } try { // se guarda los datos del usuario $user = Sentry::register(array('first_name' => Input::get('nombre'), 'last_name' => Input::get('apellido'), 'email' => Input::get('email'), 'habilitar_pin' => 1, 'celular' => Input::get('celular'), 'cedula' => Input::get('cedula'), 'password' => Input::get('password'), 'pin' => Input::get('pin'), 'porcentaje' => 0.05, 'activated' => true)); $userId = $user->getId(); $token = new Token(); $token->user_id = $userId; $token->api_token = hash('sha256', Str::random(10), false); $token->client = BrowserDetect::toString(); $token->expires_on = Carbon::now()->addMonth()->toDateTimeString(); $token->save(); // Se autentica de una $user_login = Sentry::findUserById($userId); Sentry::login($user_login, false); return Response::json(['success' => true, 'user' => $user_login, 'token' => $token->api_token]); } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { $error = array('usuario' => 'Email es requerido'); } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { $error = array('usuario' => 'Password es requerido'); } catch (Cartalyst\Sentry\Users\UserExistsException $e) { $error = array('usuario' => 'El Email ya está registrado'); } return Response::json(['success' => false, 'errors' => $error]); }
/** * Blog post create form processing. * * @return Redirect */ public function postCreate() { // Declare the rules for the form validation $rules = array('title' => 'required|min:3', 'content' => 'required|min:3'); // Validate the inputs $validator = Validator::make(Input::all(), $rules); // Check if the form validates with success if ($validator->passes()) { // Create a new blog post $post = new Post(); // Update the blog post data $post->title = Input::get('title'); $post->slug = convert_to_slug(Input::get('title')); $post->content = Input::get('content'); $post->meta_title = Input::get('meta-title'); $post->meta_description = Input::get('meta-description'); $post->meta_keywords = Input::get('meta-keywords'); $post->user_id = Sentry::getId(); // Was the blog post created? if ($post->save()) { // Redirect to the new blog post page return Redirect::to('admin/blogs/' . $post->id . '/edit')->with('success', Lang::get('admin/blogs/messages.create.success')); } // Redirect to the blog post create page return Redirect::to('admin/blogs/create')->with('error', Lang::get('admin/blogs/messages.create.error')); } // Form validation failed return Redirect::to('admin/blogs/create')->withInput()->withErrors($validator); }
public function resetAction() { // Fetch all request data. $data = Input::only('email', 'password', 'password_confirmation', 'pass_code'); // Build the validation constraint set. $rules = array('email' => array('required'), 'password' => array('required', 'confirmed', 'min:5')); $validator = Validator::make($data, $rules); if ($validator->passes()) { $user = Sentry::findUserByLogin(Input::get('email')); // Check if the reset password code is valid if ($user->checkResetPasswordCode(Input::get('pass_code'))) { // Attempt to reset the user password if ($user->attemptResetPassword(Input::get('pass_code'), Input::get('password'))) { $user->reset_password_code = ''; $user->save(); return Redirect::to('/login')->with('global_success', 'Password has been set. You can now sign in with your new password.'); } else { return Redirect::to('/reset')->with('global_error', 'System couldn\'t change your password. Please try again and if situation repeats, report to support.'); } } else { return Redirect::to('/request')->with('global_error', 'Your reset code doesn\'t match. It may be corrupted or outdated. Please make a new request.'); } } return Redirect::to('/reset/' . Input::get('pass_code'))->withErrors($validator)->with('message', 'Validation Errors!'); }
public function __construct() { if (Sentry::check()) { // User is not logged in, or is not activated $this->data['admin'] = Sentry::getUser(); } }
public function getLogout() { if (Sentry::check()) { Sentry::logout(); return Redirect::route('index'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // var_dump(Input::All()); // die; // // 'categorias_id' => 'exists:rubros,id' $rules = ['articulo' => 'required', 'copete' => 'required', 'texto' => 'required']; if (!Articulo::isValid(Input::all(), $rules)) { return Redirect::back()->withInput()->withErrors(Articulo::$errors); } $articulo = new Articulo(); $articulo->users_id = Sentry::getUser()->id; $articulo->articulo = Input::get('articulo'); $articulo->copete = Input::get('copete'); $articulo->texto = Input::get('texto'); $articulo->tipo = Input::get('tipo'); $articulo->categorias_id = Input::get('categorias_id'); $url_seo = Input::get('articulo'); $articulo->estado = 'nuevo'; //$url_seo = $this->url_slug($url_seo) . implode("-",getdate()); $url_seo = $this->url_slug($url_seo) . date('ljSFY'); $articulo->url_seo = $url_seo; $articulo->save(); return Redirect::to('/articulos/ver'); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->delete(); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => '12345678', 'first_name' => 'Administrador', 'last_name' => 'Kentron', 'activated' => 1]); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => '12345678', 'first_name' => 'Invitado', 'last_name' => 'Kentron', 'activated' => 1]); $this->command->info('Users seeded!'); }
/** * Reverse the migrations. * * @return void */ public function down() { $admins = Sentry::getGroupProvider()->findByName('Admins'); $diff = array_diff($this->permissions, $admins->permissions); $admins->permissions = $diff; $admins->save(); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->delete(); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => 'sentryuser', 'first_name' => 'UserFirstName', 'last_name' => 'UserLastName', 'activated' => 1]); Sentry::getUserProvider()->create(['email' => '*****@*****.**', 'password' => 'sentryadmin', 'first_name' => 'AdminFirstName', 'last_name' => 'AdminLastName', 'activated' => 1]); $this->command->info('Users seeded!'); }
public function run() { DB::table('users_groups')->delete(); DB::table('groups')->delete(); DB::table('users')->delete(); DB::table('throttle')->delete(); try { $group = Sentry::createGroup(array('name' => 'administrator', 'description' => 'Administrator', 'permissions' => array('admin' => 1))); $group = Sentry::createGroup(array('name' => 'operator', 'description' => 'Operator', 'permissions' => array('operator' => 1))); } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) { echo "Name file is Required"; } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) { echo "Group already exists"; } try { $admin = Sentry::register(array('email' => '*****@*****.**', 'password' => 'admin', 'first_name' => 'Administrator', 'last_name' => 'IT KSA'), true); $adminGroup = Sentry::findGroupByName('administrator'); $admin->addGroup($adminGroup); $operator = Sentry::register(array('email' => '*****@*****.**', 'password' => '090996o9o9g6!@#', 'first_name' => 'Operator', 'last_name' => 'IT KSA'), true); $operatorGroup = Sentry::findGroupByName('operator'); $operator->addGroup($operatorGroup); } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) { echo "Login field is required"; } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { echo "Password field is required"; } catch (Cartalyst\Sentry\Users\UserExistsException $e) { echo "User with this login is Required"; } catch (Cartalyst\Sentry\Users\GroupNotFoundException $e) { echo "Group was not found"; } }
public function postCreate() { $rules = array('name' => 'required', 'cover_image' => 'required|image'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('create_album_form')->withErrors($validator)->withInput(); } // end if $file = Input::file('cover_image'); $random_name = str_random(8); $destinationPath = 'albums/'; $extension = $file->getClientOriginalExtension(); $filename = $random_name . "." . $extension; $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename); $album = Album::create(array('name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename, 'user_id' => \Sentry::getUser()->id)); /* $filename = Input::file('cover_image'); $random_name = str_random(8); $destinationPath = 'albums/'; $extension = $filename->getClientOriginalExtension(); $uploadSuccess = Input::file('cover_image')->move($destinationPath, $filename . "." . $extension); $album = Album::create(array( 'name' => Input::get('name'), 'description' => Input::get('description'), 'cover_image' => $filename . "." . $extension, )); */ return Redirect::route('show_album', array('id' => $album->id)); }
public function refunds() { $properties = Property::where('agent_id', '=', Sentry::getUser()->id)->get(); $refunds = Invoice::where('type', '=', 'refund')->get(); $amountpaid = 0; return View::make('backend.code.invoice.refunds', compact('refunds', 'amountpaid', 'properties')); }
public function add_feedback() { $type = Input::get('type'); $title = Input::get('title'); $content = Input::get('content'); if (!isset($type)) { return Response::json(array('errCode' => 1, 'message' => '请选者反馈类型')); } if (!isset($title)) { return Response::json(array('errCode' => 2, 'message' => '请输入标题')); } if (!isset($content)) { return Response::json(array('errCode' => 3, 'message' => '请输入内容')); } $feedback = new Feedback(); $feedback->user_id = Sentry::getUser()->user_id; $feedback->type = $type; $feedback->title = $title; $feedback->content = $content; $feedback->status = 0; if (!$feedback->save()) { return Response::json(array('errCode' => 4, 'message' => '保存失败')); } return Response::json(array('errCode' => 0, 'message' => '保存成功')); }
public function isCurrent() { if (!Sentry::check()) { return false; } return Sentry::getUser()->id == $this->id; }
protected function setUp() { $this->current_route = Route::getCurrentRoute()->getName(); $this->logged_user = Sentry::getUser(); View::share('logged_user', $this->logged_user); View::share('current_route', $this->current_route); }
public function index() { // todo this should be moved into the repo $user = Sentry::getUser(); $faxes = $this->faxes->findByUserId($user->getId()); $this->view('fax.list', compact('faxes')); }
public function login() { $account = Input::get('account'); $password = Input::get('password'); if (!isset($account)) { return Response::json(array('error_code' => 1, 'message' => '请输入账户')); } if (!isset($password)) { return Response::json(array('error_code' => 2, 'message' => '请输入密码')); } $user = User::where('account', $account)->first(); if (!isset($user)) { return Response::json(array('error_code' => 3, 'message' => '用户名不存在')); } if (!($user->role & 0x2)) { return Response::json(array('error_code' => 4, 'message' => '无效用户')); } try { Sentry::authenticate(array('phone' => $user->phone, 'password' => $password)); } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { return Response::json(array('error_code' => 5, 'message' => '用户名或密码错误')); } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { return Response::json(array('error_code' => 5, 'message' => '用户名或密码错误')); } $doctor = Doctor::where('user_id', $user->id)->first(); Session::put('user.id', $user->id); Session::put('doctor.id', $doctor->id); Session::put('doctor.name', $doctor->name); Session::put('doctor.photo', $doctor->photo); return Response::json(array('error_code' => 0, 'message' => '登录成功')); }
public function __construct() { $this->user = Sentry::getUser(); $this->isAdmin = User::isAdmin($this->user); $this->logged_in_for = $this->user->last_login->diffForHumans(); $this->configs = Setting::getSiteSettings(); }
public function showLogin() { if (Sentry::check()) { return Redirect::to('/admin'); } return View::make('admin::vis-login'); }