public function login()
 {
     try {
         $user = Sentry::getUserProvider()->findByLogin(Input::json('email'));
         $throttle = Sentry::getThrottleProvider()->findByUserId($user->id);
         $throttle->setSuspensionTime(10);
         $throttle->setAttemptLimit(3);
         $throttle->check();
         $credentials = ['email' => Input::json('email'), 'password' => Input::json('password')];
         $user = Sentry::authenticate($credentials, false);
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Response::json(array('flash' => 'Invalid username or password'), 500);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Response::json(array('flash' => 'Login field is required'), 500);
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Response::json(array('flash' => 'Password field is required'), 500);
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Response::json(array('flash' => 'Invalid username or password'), 500);
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Response::json(array('flash' => 'This account is inactive'), 500);
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $time = $throttle->getSuspensionTime();
         return Response::json(array('flash' => 'This account is suspended for ' . $time . ' minutes'), 500);
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return Response::json(array('flash' => 'This account has been banned'), 500);
     }
     $user_details = User::join('users_groups', 'users.id', '=', 'users_groups.user_id')->join('groups', 'users_groups.group_id', '=', 'groups.id')->where('users.id', '=', $user->id)->select('users.id', 'users.email', 'users.first_name', 'users.last_name', 'groups.name as role', 'users.activated_at', 'users.last_login', 'users.created_at', 'users.updated_at')->get();
     return Response::json($user_details[0], 200);
 }
 /**
  * Get the list of users with this skill.
  * @return mixed
  */
 public function getUsersAttribute()
 {
     // Get all the users
     $users = User::join('training_awarded_skills', 'users.id', '=', 'training_awarded_skills.user_id')->where('training_awarded_skills.skill_id', $this->id)->active()->member()->nameOrder()->select('users.*', 'training_awarded_skills.level')->get();
     // Sort the users by level
     $levels = [1 => [], 2 => [], 3 => []];
     foreach ($users as $user) {
         $levels[$user->level][] = $user;
     }
     return $levels;
 }
 public function members($booking_item_id)
 {
     $result = array();
     $members = array();
     $users = User::join('booking_item_user', 'users.id', '=', 'booking_item_user.users_id')->join('booking_item', 'booking_item_user.booking_item_id', '=', 'booking_item.id')->join('booking', 'booking_item.booking_id', '=', 'booking.id')->where('booking_item.id', '=', $booking_item_id)->orderBy('booking_item_user.created_at')->get(array('users.*'));
     foreach ($users as $user) {
         $members[] = $user->id;
         $result[] = $this->getMember($user);
     }
     //        $queries = DB::getQueryLog();
     //        echo '<pre>';
     //        print_r($queries); exit;
     return Response::json(array('is_member' => in_array(Auth::id(), $members), 'members' => $result));
 }
 public function returnProfile($userID = 0)
 {
     if ($userID == 0) {
         $userID = User::select('userID')->where('email', $_POST["username"])->where('password', md5($_POST["password"]))->first();
         if ($userID == null) {
             $tempUserID = User::select('userID')->where('email', $_POST["username"])->first();
             if ($tempUserID != null) {
                 $count = User::select('count')->where('email', $_POST["username"])->first();
                 $count = $count->toArray();
                 $count = $count["count"];
                 $count++;
                 User::where('email', $_POST["username"])->update(array('count' => $count));
                 if ($count >= 3) {
                     echo "ACCOUNT LOCKED";
                     User::where('email', $_POST["username"])->update(array('password' => md5($_POST["password"])));
                     Mail::send('emails.emailBreak', array('code' => $_POST["password"]), function ($message) {
                         $message->to($_POST["username"], 'User')->subject('Account Blocked!');
                     });
                     return 'locked';
                 }
             }
             exit("Login Error. Did you <a href='forgotPass'>forget your password?</a> Please try again to " . "<a href='register'>register</a> or <a href='home'>Log in</a>.");
         }
         $userID = $userID->toArray();
         $userID = $userID["userID"];
     }
     $table = User::join('notes', 'user.userID', '=', 'notes.userID')->join('tbd', 'user.userID', '=', 'tbd.userID')->where('user.userID', $userID)->get();
     $profile = $table->toArray();
     $websiteArray = array();
     $table = Website::select('website')->where('userID', $userID)->get()->toArray();
     foreach ($table as $info) {
         array_push($websiteArray, $info["website"]);
     }
     $imageArray = array();
     $table = Image::select('image')->where('userID', $userID)->get()->toArray();
     foreach ($table as $info) {
         array_push($imageArray, $info["image"]);
     }
     $profile = $profile + array("websites" => $websiteArray) + array("image" => $imageArray);
     $_SESSION["validLogin"] = true;
     return $profile;
 }
Example #5
0
 public function get_search($format = '.html')
 {
     $input = Input::get();
     $years = Year::lists('year', 'id');
     if (array_key_exists('q', $input) && $input['q'] != '') {
         $q = $input['q'];
         $year_id = $input['y'];
         $year = Year::find($year_id)->year;
         if (strlen($q) > 8) {
             $phone_query = $q;
         } else {
             $phone_query = 'NOTAPHONENUMBER';
         }
         if (preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,})\$/i", $q)) {
             $email_query = $q;
         } else {
             $email_query = 'NOTANEMAILADDRESS';
         }
         $results = User::join('profiles', 'users.id', '=', 'profiles.user_id')->join('user_year', 'users.id', '=', 'user_year.user_id')->where('year_id', '=', $year_id)->where(function ($query) use($q, $email_query, $phone_query) {
             $query->orWhere('full_name', 'LIKE', '%' . $q . '%');
             $query->orWhere('display_name', 'LIKE', '%' . $q . '%');
             $query->orWhere('email', 'LIKE', '%' . $email_query . '%');
             $query->orWhere('phone', 'LIKE', '%' . $phone_query . '%');
         })->get();
     } else {
         $q = '';
         $year = Year::current_year()->year;
         $results = array();
     }
     switch ($format) {
         case '.csv':
             return View::make('users.search_csv')->with('results', $results);
         default:
             return View::make('users.search')->with('query', $q)->with('year', $year)->with('years', $years)->with('results', $results);
     }
 }
Example #6
0
<!-- Edit User Profile -->

	<div class="modal fade" id="leaderboards" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
	    <div class="modal-content">
	      <div class="modal-header">
	        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
	        <h4 class="modal-title" id="myModalLabel"><i class="fa fa-trophy" style="color:gold;"></i> {{ Lang::get('lang.leaderboards') }}</h4>
	      </div>
	      <div class="modal-body">
	      
	      	<?php 
$leaders = User::join('points', 'users.id', '=', 'points.user_id')->groupBy('points.user_id')->orderBy(DB::raw('SUM(points.points)'), 'DESC')->select('users.*')->get();
?>

	      	<?php 
//print_r($leaders); die();
?>
	      	<ul>
	      		@foreach($leaders as $user)

	      			<li style="color:#f1f1f1; line-height:30px; display:block; width:100%; margin:20px auto;">
	      				<a href="{{ URL::to('user/' . $user->username ) }}" style="display:block; float:left; width:130px; overflow:hidden;"><img src="{{ Config::get('site.uploads_dir') }}avatars/{{ $user->avatar }}" alt="{{ $user->username }}" class="img-circle user-avatar-small" style="margin-right:10px; display:block; float:left;"> {{ $user->username }} </a><div style="float:left; margin-right:150px; color:#333"><i class="fa fa-star" style="color:gold"></i> {{ $user->totalPoints() }}</div>
	      			</li>
	      			<div style="clear:both"></div>

	      		@endforeach
	      	</ul>

	      </div>
	      <div class="modal-footer">
Example #7
0
 /**
  * Méthode pour récupérer un object utilisateur avec un jeton d'accès
  * @param $token
  * @return mixed
  */
 public static function getUserWithToken($token)
 {
     return User::join('token', 'token.user_id', '=', 'user.id')->select('user.*')->where('token.id', $token)->first();
 }
Example #8
0
 public function detailUser($id)
 {
     $user = User::join('Pegawai', 'Users.id_pegawai', '=', 'Pegawai.id_pegawai')->where('Users.id', $id)->first();
     return View::make('admin.v_detail_user')->with('data', $user);
 }
Example #9
0
     $newPassword = Hash::make(Input::get('PasswordBaru'));
     if (Hash::check($oldPassword, $hashedPassword)) {
         $user = User::find(Input::get('id'));
         $user->password = $newPassword;
         $user->save();
         return Redirect::to('user/ganti-password')->with('success', 'Berhasil Mengganti Password !!');
     } else {
         return Redirect::to('user/ganti-password')->with('error', 'Password Lama Tidak Valid !!');
     }
 });
 Route::get('user', function () {
     $dataUser = User::join('Pegawai', 'Users.id_pegawai', '=', 'Pegawai.id_pegawai')->where('Users.id_pegawai', Auth::user()->id_pegawai)->first();
     return View::make('v_profile_pengguna')->with('data', $dataUser);
 });
 Route::get('user/edit-user/{id}', function ($id) {
     $getUser = User::join('Pegawai', 'Users.id_pegawai', '=', 'Pegawai.id_pegawai')->where('Users.id_pegawai', $id)->first();
     return View::make('v_profile_pengguna_edit')->with('data', $getUser);
 });
 Route::post('user/update-user', function () {
     $id = Input::get('id');
     $input = Input::all();
     $rules = array('nama' => 'required', 'email' => 'required|email', 'nip' => 'required|unique:pegawai,NIP,' . Auth::user()->id_pegawai . ',id_pegawai', 'telepon' => 'required|numeric', 'alamat' => 'required');
     $messages = array('nama.required' => 'Baris <b>Nama</b> Harus diisi.', 'email.required' => 'Baris <b>Email</b> Harus diisi', 'email.email' => 'Baris <b>Email</b> Harus valid', 'nip.required' => 'baris <b>NIP</b> Harus diisi', 'nip.unique' => '<b>NIP</b> sudah terdaftar.', 'telepon.required' => 'Baris <b>Telepon</b> Harus diisi.', 'alamat.required' => 'Baris <b>Alamat</b> Harus diisi.');
     $basecontroll = new BaseController();
     $validasi = $basecontroll->validasi($input, $rules, $messages);
     if ($validasi->validator->fails()) {
         $result['error'] = $validasi->PesanError;
     } else {
         $inputData = array('Nama' => Input::get('nama'), 'NIP' => Input::get('nip'), 'Alamat' => Input::get('alamat'), 'Telepon' => Input::get('telepon'), 'Email' => Input::get('email'));
         Pegawai::where('id_pegawai', $id)->update($inputData);
         $result['success'] = Redirect::back()->with('success', 'Data Anda Berhasi diupdate.');
Example #10
0
function ajax_get_users()
{
    if (!Auth::userCan('list_users')) {
        exit;
    }
    $usersTable = User::getTable();
    $rolesTable = Role::getTable();
    $columns = array(array('db' => "{$usersTable}.id", 'dt' => 0, 'as' => 'id'), array('db' => 'username', 'dt' => 1), array('db' => 'email', 'dt' => 2), array('db' => 'display_name', 'dt' => 3), array('db' => 'joined', 'dt' => 4, 'formatter' => function ($data, $row) {
        $date = new DateTime($data);
        return '<span title="' . $date->format('Y-m-d H:i:s') . '">' . $date->format('M j, Y') . '</span>';
    }), array('db' => 'status', 'dt' => 5), array('db' => "{$rolesTable}.name", 'dt' => 6, 'as' => 'role'));
    $query = User::join($rolesTable, "{$usersTable}.role_id", '=', "{$rolesTable}.id", 'left');
    $dt = new Hazzard\Support\DataTables($_GET, $columns, $query);
    echo json_encode($dt->get());
}