/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $date = \Carbon\Carbon::now();
     $validator = Validator::make($data = Input::all(), User::$rules);
     $validatora = Validator::make($dataa = Input::all(), Registrasi::$rules);
     if ($validatora->fails()) {
         return Redirect::back()->withErrors($validatora)->withInput();
     } else {
         if ($validator->fails()) {
             return Redirect::back()->withErrors($validator)->withInput();
         } else {
             // Register User tanpa diaktivasi
             $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('name'), 'last_name' => Input::get('jenjang')), false);
             // Cari grup user
             $regularGroup = Sentry::findGroupByName('user');
             // Masukkan user ke grup user
             $user->addGroup($regularGroup);
             DB::table('schools')->insertGetId(array('jenjang' => input::get('jenjang'), 'name' => Input::get('name'), 'adstreet' => Input::get('adstreet'), 'advillage' => Input::get('advillage'), 'addistricts' => Input::get('addistricts'), 'adcity' => Input::get('adcity'), 'adpostalcode' => Input::get('adpostalcode'), 'adphone' => Input::get('adphone'), 'hmname' => Input::get('hmname'), 'hmphone' => Input::get('hmphone'), 'hmmobile' => Input::get('hmphone'), 'user_id' => $user->id, 'created_at' => $date, 'updated_at' => $date));
             // Persiapkan activation code untuk dikirim ke email
             $data = ['email' => $user->email, 'activationCode' => $user->getActivationCode()];
             // Kirim email aktivasi
             Mail::send('emails.auth.register', $data, function ($message) use($user) {
                 $message->to($user->email, $user->first_name . ' ' . $user->last_name)->subject('Aktivasi Akun SIM Atletik UNESA');
             });
             // Redirect ke halaman login
             return Redirect::route('login')->with("successMessage", "Berhasil disimpan. Silahkan cek email ({$user->email}) untuk melakukan aktivasi akun.");
         }
     }
 }
Example #2
0
 /**
  * @return string
  * User Registration.
  */
 public function postRegister()
 {
     $input = Input::only('firstname', 'lastname', 'email', 'password', 'confirm_password');
     try {
         $rules = array('firstname' => 'required|min:2', 'lastname' => 'required|min:2', 'email' => 'required|email|unique:users', 'password' => 'required|min:4', 'confirm_password' => 'required|same:password');
         $messages = array('required' => 'Het :attribute veld is verplicht in te vullen.', 'min' => 'Het :attribute veld moet minstens 2 karakters bevatten.');
         $validator = Validator::make($input, $rules, $messages);
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         } else {
             unset($input['confirm_password']);
             $user = Sentry::register($input);
             $activationCode = $user->getActivationCode();
             $data = array('token' => $activationCode);
             Mail::send('emails.auth.welcome', $data, function ($message) use($user) {
                 $message->from('*****@*****.**', 'Site Admin');
                 $message->to($user['email'], $user['first_name'], $user['last_name'])->subject('Welcome to My Laravel app!');
             });
             if (count(Mail::failures()) > 0) {
                 $errors = 'Failed to send password reset email, please try again.';
             }
             if ($user) {
                 return Redirect::action('AuthController@login');
             }
         }
     } catch (Sentry\SentryException $e) {
         // Create custom error msgs.
     }
 }
Example #3
0
 public function run()
 {
     //Hapus isi table users, groups, users_groups dan Throttle
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         //Membuat grup admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo 'Group already exists';
     }
     try {
         //Membuat admin baru
         $admin = Sentry::register(array('username' => 'admin', 'password' => 'admin', 'first_name' => 'Admin', 'last_name' => 'Koperasi'), true);
         //Langsung diaktivasi
         //Cari Group Admin
         $adminGroup = Sentry::findGroupByName('admin');
         //Masukkan user ke Group admin
         $admin->addGroup($adminGroup);
     } 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 already exists.';
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
 }
 public function store()
 {
     $v = Validator::make($data = Input::all(), User::$rules);
     if ($v->fails()) {
         return Response::json(array($v->errors()->toArray()), 500);
         // return Response::json(array('flash' => 'Something went wrong, try again !'), 500);
     } else {
         $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')), true);
         if (Input::hasFile('picture')) {
             $uploaded_picture = Input::file('picture');
             // mengambil extension file
             $extension = $uploaded_picture->getClientOriginalExtension();
             // membuat nama file random dengan extension
             $filename = md5(time()) . '.' . $extension;
             $destinationPath = public_path() . DIRECTORY_SEPARATOR . 'img/photos';
             // memindahkan file ke folder public/img/photos
             $uploaded_picture->move($destinationPath, $filename);
             // mengisi field picture di user dengan filename yang baru dibuat
             $user->picture = $filename;
             $user->save();
         }
         // Find the similiar group
         $GroupId = Sentry::findGroupById(Input::get('group_id'));
         // Insert user user into specified group
         $user->addGroup($GroupId);
         return Response::json(array('flash' => 'New user has been successfully created !'), 200);
     }
 }
Example #5
0
 /**
  * Perform user registration.
  */
 public function postRegister()
 {
     $userdata = ['_id' => strtolower(Input::get('username')), 'firstname' => ucfirst(strtolower(Input::get('firstname'))), 'lastname' => ucfirst(strtolower(Input::get('lastname'))), 'email' => strtolower(Input::get('email')), 'password' => Input::get('password'), 'confirm_password' => Input::get('confirm_password')];
     $rules = ['_id' => 'required|min:3|unique:useragents', 'firstname' => 'required|min:3', 'lastname' => 'required|min:1', 'email' => 'required|email|unique:useragents', 'password' => 'required|min:5', 'confirm_password' => 'required|same:password'];
     $validation = Validator::make($userdata, $rules);
     if ($validation->fails()) {
         $msg = '<ul>';
         foreach ($validation->messages()->all() as $message) {
             $msg .= "<li>{$message}</li>";
         }
         Session::flash('flashError', "{$msg}</ul>");
         return Redirect::back()->withInput(Input::except('password', 'confirm_password'));
     }
     unset($userdata['confirm_password']);
     $user = Sentry::register($userdata);
     Auth::login($user);
     // Assign to groups ?
     $iCode = Input::get('invitation');
     $sentryGroup = SentryGroup::where('invite_code', '=', $iCode)->first();
     if (!is_null($sentryGroup)) {
         $user->addGroup($sentryGroup);
         Session::flash('flashSuccess', 'You have joined group: <b>' . $sentryGroup['name'] . '</b>');
     }
     return Redirect::to('/');
 }
Example #6
0
 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]);
 }
 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";
     }
 }
Example #8
0
 public function action_register_complete()
 {
     $form_values = array('email' => '', 'password' => '', 'first_name' => '', 'last_name' => '');
     if ($this->request->post() != null) {
         try {
             // Let's register a user.
             $user = Sentry::register(array_merge($form_values, $this->request->post()));
             // Let's get the activation code
             $activationCode = $user->getActivationCode();
             Hint::set(Hint::SUCCESS, 'Your activation code is: ' . $activationCode);
             //everything went successful, send the user somewhere else
             $this->redirect(Route::url('S4K.users.register', null, true));
             //@todo normally you wouldn't redirect back to the register
             //@todo Send activation code to the user so he can activate the account
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors('orm');
             //make hints out of the errors
             foreach ($errors as $error) {
                 Hint::set(Hint::ERROR, $error);
             }
             //redisplay the register form
             $this->_tpl->hints = Hint::render(null, true, 's4k/hint');
             $this->action_register($this->request->post());
         }
     } else {
         // no post request made, send back
         $this->redirect(Route::url('S4K.users.register', null, true));
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|min:4|max:254|email', 'password' => 'required|min:6|confirmed', 'password_confirmation' => 'required', 'group' => 'required');
     $validator = Validator::make($input, $rules);
     if ($validator->passes()) {
         $result = array();
         try {
             $user = \Sentry::register(array('email' => $input['email'], 'password' => $input['password'], 'first_name' => $input['first_name'], 'last_name' => $input['last_name']));
             $group = \Sentry::findGroupById($input['group']);
             $user->addGroup($group);
             $this->mailer->welcome($user);
             $result['success'] = true;
             $result['message'] = 'Activation code is sent , please check your email';
         } catch (Exception\LoginRequiredException $e) {
             $result['success'] = false;
             $result['message'] = 'Login field is required.';
         } catch (Exception\PasswordRequiredException $e) {
             $result['success'] = false;
             $result['message'] = 'Password field is required.';
         } catch (Exception\UserExistsException $e) {
             $result['success'] = false;
             $result['message'] = 'User with this login already exists';
         }
         return Redirect::route('users.index')->with('message', $result['message']);
         //return Redirect::route('users.index')->with('message','Successfully Registered');
     }
     return Redirect::route('users.create')->withInput()->withErrors($validator);
 }
Example #10
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->info('Seeding table');
     DB::connection()->disableQueryLog();
     Eloquent::unguard();
     // Configuring curl options
     $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => array('Content-type: application/json'));
     $start = $this->argument('start');
     $userGroup = Sentry::getGroupProvider()->findByName('user');
     for ($i = $start; $i < $start + 1000; $i++) {
         // jSON URL which should be requested
         $json_url = 'http://graph.facebook.com/' . $i;
         $this->info('Querying ' . $json_url);
         // Initializing curl
         $ch = curl_init($json_url);
         // Setting curl options
         curl_setopt_array($ch, $options);
         // Getting results
         $result = curl_exec($ch);
         // Getting jSON result string
         $json = json_decode($result);
         if (is_object($json) && !property_exists($json, 'error')) {
             $this->info('Creating ' . $json->first_name . ' ' . $json->last_name);
             $user = Sentry::register(array('first_name' => $json->first_name, 'last_name' => $json->last_name, 'email' => strtolower($json->first_name . '_' . $json->last_name) . '_' . $i . '@facebook.com', 'password' => 'password'), true);
             $user->addGroup($userGroup);
             Facebook::create(array('user_id' => $user->id, 'oauth_uid' => $i));
         } else {
             $this->error($json->error->message);
         }
     }
 }
 public function setup()
 {
     $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json($validator->messages());
     } else {
         $setting = new Setting();
         $setting->sitename = Input::get('sitename');
         $setting->save();
         $list = new Addressbook();
         $list->name = 'General';
         $list->save();
         try {
             $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')), true);
             $feedback = array('success' => 'Great! Your system is ready to roll! You will be redirected to login form in 3 seconds.');
             return Response::json($feedback);
         } 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 already exists.';
         }
     }
 }
Example #12
0
 public function run()
 {
     Sentry::register(['email' => '*****@*****.**', 'username' => 'admin', 'phone' => '132478888882', 'avatar' => 'http://7xk6xh.com1.z0.glb.clouddn.com/avatar.png', 'password' => '666666', 'info' => '简介,即简明扼要的介绍。是当事人全面而简洁地介绍情况的一种书面表达方式,它是应用写作学研究的一种日常应用文体', 'role_id' => 3, 'activated' => 1]);
     Sentry::register(['email' => '*****@*****.**', 'username' => 'tiger1', 'phone' => '13247888888', 'avatar' => 'http://7xk6xh.com1.z0.glb.clouddn.com/avatar.png', 'password' => '666666', 'info' => '简介,即简明扼要的介绍。是当事人全面而简洁地介绍情况的一种书面表达方式,它是应用写作学研究的一种日常应用文体', 'role_id' => 2, 'activated' => 1]);
     Sentry::register(['email' => '*****@*****.**', 'username' => 'tiger2', 'phone' => '13247888887', 'avatar' => 'http://7xk6xh.com1.z0.glb.clouddn.com/avatar.png', 'password' => '666666', 'info' => '简介,即简明扼要的介绍。是当事人全面而简洁地介绍情况的一种书面表达方式,它是应用写作学研究的一种日常应用文体', 'role_id' => 2, 'activated' => 1]);
     Sentry::register(['email' => '*****@*****.**', 'username' => 'tiger3', 'phone' => '13247888884', 'avatar' => 'http://7xk6xh.com1.z0.glb.clouddn.com/avatar.png', 'info' => '简介,即简明扼要的介绍。是当事人全面而简洁地介绍情况的一种书面表达方式,它是应用写作学研究的一种日常应用文体', 'password' => '666666', 'role_id' => 2, 'activated' => 1]);
 }
Example #13
0
 public function run()
 {
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         //membuat group admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         //membuat group guru
         $guru = Sentry::createGroup(array('name' => 'guru', 'permissions' => array('guru' => 1)));
         //membuat group siswa
         $siswa = Sentry::createGroup(array('name' => 'siswa', 'permissions' => array('siswa' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo "Nama Group harus diisi";
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo "Group Sudah Ada";
     }
     try {
         //membuat admin baru
         $admin = Sentry::register(array('password' => 'admin123', 'username' => 'Admin'), true);
         //cari group admin
         $adminGroup = Sentry::findGroupByName('admin');
         //masukan user ke group admin
         $admin->addGroup($adminGroup);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo "Field login harus diisi";
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo "Password harus diisi";
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         echo "User dengan akun ini sudah ada";
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo "Group tidak ada";
     }
 }
Example #14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ID 1
     $admin = \Sentry::register(['email' => env('ADMIN_EMAIL'), 'password' => env('ADMIN_PASSWORD'), 'timezone' => env('ADMIN_TIMEZONE')], true);
     // ID 1
     $adminGroup = \Sentry::createGroup(array('name' => 'Superuser', 'permissions' => array('superuser' => 1)));
     $admin->addGroup($adminGroup);
 }
Example #15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     $this->call('UserSeeder');
     Sentry::register(array('email' => '*****@*****.**', 'password' => 123456), true);
     $this->call('CompanySeeder');
     $this->call('CheckSeeder');
 }
Example #16
0
 /**
  * Handle a registration request for the application.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $this->validate($request, $this->registerUserRules);
     try {
         \Sentry::register(array('email' => $request->input('email'), 'password' => $request->input('password'), 'first_name' => $request->input('first_name'), 'last_name' => $request->input('last_name'), 'comment' => $request->input('company')));
         \Session::flash('info', trans('auth.register.awaiting-activation'));
         return redirect()->route('dashboard');
     } catch (\Exception $e) {
         abort(503);
     }
 }
Example #17
0
 public function register($fields, $groupname)
 {
     try {
         $user = \Sentry::register(array('email' => $fields['email'], 'first_name' => $fields['first_name'], 'last_name' => $fields['last_name'], 'password' => $fields['password']));
         $group = \Sentry::getGroupProvider()->findByName($groupname);
         $user->addGroup($group);
         return $user;
     } catch (\Cartalyst\Sentry\Users\UserExistsException $e) {
         $this->errors[] = trans('auth.user_exists');
     }
 }
Example #18
0
 public function run()
 {
     // Create Admins
     $adminGroup = Sentry::getGroupProvider()->findByName('admin');
     Sentry::register(array('first_name' => 'Super', 'last_name' => 'User', 'email' => '*****@*****.**', 'password' => 'password', 'permissions' => array('superuser' => 1)), true)->addGroup($adminGroup);
     Sentry::register(array('first_name' => 'Thomas', 'last_name' => 'Welton', 'email' => '*****@*****.**', 'password' => substr(md5(uniqid()), 0, 16), 'permissions' => array('superuser' => 1)), true)->addGroup($adminGroup);
     Sentry::register(array('first_name' => 'Admin', 'last_name' => 'User', 'email' => '*****@*****.**', 'password' => 'password'), true)->addGroup($adminGroup);
     // Create Users
     $userGroup = Sentry::getGroupProvider()->findByName('user');
     Sentry::register(array('first_name' => 'Example', 'last_name' => 'User', 'email' => '*****@*****.**', 'password' => 'password'), true)->addGroup($userGroup);
 }
Example #19
0
 /**
  * Run the user seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users_groups')->delete();
     DB::table('users')->delete();
     DB::table('groups')->delete();
     $defaultUser = Config::get('auth.default');
     if (is_array($defaultUser)) {
         $user = Sentry::register($defaultUser, true);
         echo "User {$defaultUser['email']} created with password {$defaultUser['password']}\n";
         $adminGroup = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         $user->addGroup($adminGroup);
     }
 }
 public function postRegister()
 {
     $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users,email,:id', 'password' => 'required', 'password_confirmation' => 'required|same:password');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput(Input::except('password', 'password_confirm'));
     } else {
         $user = Sentry::register(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'email' => Input::get('email'), 'password' => Input::get('password')), false);
         $userGroup = Sentry::findGroupByName('user');
         $user->addGroup($userGroup);
         return View::make('dashboard.guest.registermessage');
     }
 }
 /**
  * Try to register the user
  * @param array $data
  * @return boolean|\Cartalyst\Sentry\Users\Eloquent\User
  */
 public function addUser($data)
 {
     try {
         return \Sentry::register($data, true);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         \Session::flash('errors', array('email' => array('An email address is required.')));
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         \Session::flash('errors', array('password' => array('A password is required.')));
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         \Session::flash('errors', array('email' => array('A user with this email address already exists.')));
     }
     return false;
 }
 public function run()
 {
     // Refresh users
     DB::table('users')->truncate();
     // ItsTheRob
     $rob = array('first_name' => 'Rob', 'last_name' => 'Bertholf', 'email' => '*****@*****.**', 'password' => 'asdfasdf');
     Sentry::register($rob, true);
     // Administrator user
     $administrator = array('first_name' => 'Benevolent', 'last_name' => 'Dictator', 'email' => '*****@*****.**', 'password' => 'sup3rs3cr3t');
     Sentry::register($administrator, true);
     // Normal user
     $foo = array('first_name' => 'Mr.', 'last_name' => 'Foo', 'email' => '*****@*****.**', 'password' => 'f00b4r');
     Sentry::register($foo, true);
 }
Example #23
0
 public function run()
 {
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 22, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 22, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 22, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 10, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 11, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 20, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 20, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 20, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 20, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 21, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
     Sentry::register(['login_account' => '*****@*****.**', 'password' => 666666, 'status' => 30, 'user_type' => 1, 'remark_code' => 666666, 'activated' => 1]);
 }
 public function execSignUp()
 {
     $validation_rule = array('email' => 'required|email|unique:users', 'password' => 'required|min:4');
     $validator = Validator::make(Input::all(), $validation_rule);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator);
     }
     try {
         Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password')), true);
         return Redirect::route('employees.index');
     } catch (Exception $e) {
         $this->messageBag->add('all', Lang::get('auth/message.signup.error') . $e->getMessage());
     }
     return Redirect::back()->withInput()->withErrors($this->messageBag);
 }
 /**
  *
  *
  * @return void
  */
 public function callback()
 {
     $config = Config::get('opauth');
     $Opauth = new Opauth($config, FALSE);
     if (!session_id()) {
         session_start();
     }
     $response = isset($_SESSION['opauth']) ? $_SESSION['opauth'] : array();
     $err_msg = null;
     unset($_SESSION['opauth']);
     if (array_key_exists('error', $response)) {
         $err_msg = 'Authentication error:Opauth returns error auth response.';
     } else {
         if (empty($response['auth']) || empty($response['timestamp']) || empty($response['signature']) || empty($response['auth']['provider']) || empty($response['auth']['uid'])) {
             $err_msg = 'Invalid auth response: Missing key auth response components.';
         } elseif (!$Opauth->validate(sha1(print_r($response['auth'], true)), $response['timestamp'], $response['signature'], $reason)) {
             $err_msg = 'Invalid auth response: ' . $reason;
         }
     }
     if ($err_msg) {
         return Redirect::to('account/login')->with('error', $err_msg);
     } else {
         $email = $response['auth']['info']['email'];
         $authentication = new Authentication();
         $authentication->provider = $response['auth']['provider'];
         $authentication->provider_uid = $response['auth']['uid'];
         $authentication_exist = Authentication::where('provider', $authentication->provider)->where('provider_uid', '=', $authentication->provider_uid)->first();
         if (!$authentication_exist) {
             if (Sentry::check()) {
                 $user = Sentry::getUser();
                 $authentication->user_id = $user->id;
             } else {
                 try {
                     $user = Sentry::getUserProvider()->findByLogin($email);
                 } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                     $user = Sentry::register(array('first_name' => $response['auth']['info']['first_name'], 'last_name' => $response['auth']['info']['last_name'], 'email' => $email, 'password' => Str::random(14)), TRUE);
                 }
                 $authentication->user_id = $user->id;
             }
             $authentication->save();
         } else {
             $user = Sentry::getUserProvider()->findById($authentication_exist->user_id);
             Sentry::login($user);
             Session::put('user_image', $response['auth']['info']['image']);
             return Redirect::to('/');
         }
     }
 }
Example #26
0
 public function askPermission()
 {
     $provider = new League\OAuth2\Client\Provider\Facebook(array('clientId' => '372319239612356', 'clientSecret' => '8c78a15dfaa0bf16a81191b68ec89638', 'redirectUri' => 'http://www.subbly.dev/auth'));
     if (!isset($_GET['code'])) {
         // If we don't have an authorization code then get one
         header('Location: ' . $provider->getAuthorizationUrl());
         exit;
     } else {
         // Try to get an access token (using the authorization code grant)
         $token = $provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
         // Optional: Now you have a token you can look up a users profile data
         try {
             // We got an access token, let's now get the user's details
             $userDetails = $provider->getUserDetails($token);
             // Use these details to create a new profile
             printf('Hello %s!', $userDetails->firstName);
         } catch (Exception $e) {
             // Failed to get user details
             exit('Oh dear...');
         }
         try {
             // Find the user using the user id
             $user = Sentry::findUserByLogin($userDetails->email);
             // Log the user in
             Sentry::login($user, false);
             // return Redirect::route('home');
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             // Register the user
             $user = Sentry::register(array('activated' => 1, 'email' => $userDetails->email, 'password' => Hash::make(uniqid(time())), 'first_name' => $userDetails->firstName));
             // $usergroup = Sentry::getGroupProvider()->findById(2);
             // $user->addGroup($usergroup);
             Sentry::login($user, false);
             // return Redirect::route('account');
         }
         Debugbar::info($userDetails);
         Debugbar::info($user);
         // exit;
         // Use this to interact with an API on the users behalf
         echo $token->accessToken;
         // Use this to get a new access token if the old one expires
         echo $token->refreshToken;
         // Number of seconds until the access token will expire, and need refreshing
         echo $token->expires;
     }
 }
Example #27
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Fetch all request data.
     $data = Input::only('nickname', 'email', 'password', 'password_confirmation', 'tos', 'city');
     // Build the validation constraint set.
     $rules = array('email' => array('required', 'email', 'unique:users,email'), 'password' => array('required', 'confirmed', 'min:5'), 'tos' => array('accepted'), 'city' => array('size:0'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $user = Sentry::register(array('nickname' => Input::get('nickname'), 'email' => Input::get('email'), 'password' => Input::get('password')));
         $activationCode = $user->getActivationCode();
         Mail::send('emails.activate', array('activation_code' => $activationCode, 'user_id' => $user->id, 'nick' => Input::get('nick')), function ($message) {
             $message->to(Input::get('email'), Input::get('nick'))->subject('Welcome!');
         });
         return Redirect::to('/')->with('global_success', 'Activation code has been sent to your email address.');
     }
     return Redirect::to('/register')->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
Example #28
0
 public function run()
 {
     DB::table('users_groups')->delete();
     DB::table('groups')->delete();
     DB::table('users')->delete();
     DB::table('throttle')->delete();
     try {
         // create grup admin
         $group = Sentry::createGroup(array('name' => 'admin', 'permissions' => array('admin' => 1)));
         // create grup sales
         $group = Sentry::createGroup(array('name' => 'salesman', 'permissions' => array('sales' => 1)));
     } catch (Cartalyst\Sentry\Groups\NameRequiredException $e) {
         echo 'Name field is required';
     } catch (Cartalyst\Sentry\Groups\GroupExistsException $e) {
         echo 'Group already exists';
     }
     try {
         /*
          ** Admininistrator
          **
          */
         $admin = Sentry::register(array('email' => '*****@*****.**', 'password' => 'admin', 'first_name' => 'Super', 'last_name' => 'Administrator'), true);
         $adminGroup = Sentry::findGroupByName('admin');
         // Masukkan user ke grup admin
         $admin->addGroup($adminGroup);
         /*
          ** Salesman
          **
          */
         $user = Sentry::register(array('email' => '*****@*****.**', 'password' => 'salesman', 'first_name' => 'Yefta', 'last_name' => 'Aditya Wibowo'), true);
         // Cari grup salesman
         $salesmanGroup = Sentry::findGroupByName('salesman');
         // Masukkan user ke grup salesman
         $user->addGroup($salesmanGroup);
     } 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 already exists.';
     } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
         echo 'Group was not found.';
     }
 }
Example #29
0
 /**
  * Send User Actication Email
  * @param string, string
  * @return bool
  */
 public static function sendUserActivationEmail($email, $role)
 {
     $tempPassword = Str::random(9);
     try {
         $user = Sentry::register(array('email' => $email, 'password' => $tempPassword));
         $activationCode = $user->getActivationCode();
         $group = Sentry::findGroupbyName($role);
         $user->addGroup($group);
         $link = (string) url() . '/auth/activateuser?activation_token=' . $activationCode . '&email=' . $email;
         $data = array('link' => $link);
         Mail::queue('emails.auth.activateuser', $data, function ($message) use($email) {
             $message->to($email)->subject('Invitation to Join 92five app');
         });
         return true;
     } catch (Exception $e) {
         Log::error('Something went Wrong in Email Class - sendUserActivationEmail():' . $e->getMessage());
         return false;
     }
 }
 public function getRegister()
 {
     if (Sentry::check()) {
         return Redirect::to('account');
     } else {
         if (Input::has('username') && Input::has('password') && Input::has('email')) {
             try {
                 $username = Input::get('username');
                 $email = Input::get('email');
                 $password = Input::get('password');
                 $user = Sentry::register(array('username' => $username, 'email' => $email, 'password' => $password, 'activated' => true));
                 return View::make('account', ['title' => 'Sign up'])->nest('register_form', 'child.register')->nest('update_msg', 'child.alerts', array('msg_type' => 'success', 'msg' => 'You have been registered as <strong>' . $username . '</strong>, feel free to sign in' . link_to('account', 'here') . '.'));
             } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
                 return View::make('account', ['title' => 'Sign up'])->nest('register_form', 'child.register')->nest('update_msg', 'child.alerts', array('msg_type' => 'warning', 'msg' => 'Username already exists!'));
             }
         } else {
             return View::make('account', ['title' => 'Sign up'])->nest('register_form', 'child.register');
         }
     }
 }