Inheritance: extends Illuminate\Database\Eloquent\Model, implements Illuminate\Contracts\Auth\Authenticatable, implements Illuminate\Contracts\Auth\CanResetPassword, use trait Illuminate\Auth\Authenticatable, use trait Illuminate\Auth\Passwords\CanResetPassword
 public function facebook(Request $request)
 {
     $accessTokenUrl = 'https://graph.facebook.com/v2.5/oauth/access_token';
     $graphApiUrl = 'https://graph.facebook.com/v2.5/me';
     $params = ['code' => $request->input('code'), 'client_id' => $request->input('clientId'), 'redirect_uri' => $request->input('redirectUri'), 'client_secret' => '76cd1014c10586c33f3e13f03929a221'];
     $client = new \GuzzleHttp\Client();
     // Step 1. Exchange authorization code for access token.
     $accessToken = json_decode($client->get($accessTokenUrl, ['query' => $params])->getBody(), true);
     // Step 2. Retrieve profile information about the current user.
     $profile = json_decode($client->get($graphApiUrl, ['query' => $accessToken])->getBody(), true);
     // Step 3a. If user is already signed in then link accounts.
     if ($request->header('Authorization')) {
         $user = User::where('facebook', '=', $profile['id']);
         if ($user->first()) {
             return response()->json(['message' => 'There is already a Facebook account that belongs to you'], 409);
         }
         $token = explode(' ', $request->header('Authorization'))[1];
         $payload = (array) JWT::decode($token, Config::get('jwt.secret'), array('HS256'));
         $user = User::find($payload['sub']);
         $user->facebook = $profile['id'];
         $user->displayName = $user->displayName ?: $profile['name'];
         $user->save();
         return response()->json(['token' => $this->createToken($user)]);
     } else {
         $user = User::where('facebook', '=', $profile['id']);
         if ($user->first()) {
             return response()->json(['token' => $this->createToken($user->first())]);
         }
         $user = new User();
         $user->facebook = $profile['id'];
         $user->displayName = $profile['name'];
         $user->save();
         return response()->json(['token' => $this->createToken($user)]);
     }
 }
 public function transform(User $user = null)
 {
     if (!$user) {
         return null;
     }
     return $user->toArray();
 }
 /**
  * Create a new event instance.
  *
  * @return void
  */
 public function __construct($EcNa, $typ, $eml, $pass, $nomresp, $fix, $port, $adres, $ville, $pays)
 {
     $this->ecoleNom = $EcNa;
     $this->type = $typ;
     $this->email = $eml;
     $this->password = $pass;
     $this->nomResponsable = $nomresp;
     $this->fix = $fix;
     $this->portab = $port;
     $this->adresse = $adres;
     $this->ville = $ville;
     $this->pays = $pays;
     $user = new User();
     $user->name = $this->ecoleNom;
     $user->type = $this->type;
     $user->email = $this->email;
     $user->password = \Hash::make($this->password);
     $user->nom_responsable = $this->nomResponsable;
     $user->tel_fixe = $this->fix;
     $user->tel_portable = $this->portab;
     $user->adresse = $this->adresse;
     $user->ville = $this->ville;
     $user->pays = $this->pays;
     $user->save();
     if ($user) {
         $info = ['nom_resp' => $this->nomResponsable, 'nom_ecole' => $this->ecoleNom, 'email' => $this->email, 'pass' => $this->password];
         Mail::queue('emails.school', $info, function ($message) {
             $message->to($this->email, 'ok')->from('creche@gmail.com')->subject('Bienvenue  !');
         });
     }
 }
Example #4
0
 public function select(User $user)
 {
     $educations = $user->educations()->latest()->paginate(20);
     $infos = $user->info()->latest()->paginate(20);
     $bio = $user->biography()->first();
     return view('admin.users.management', compact('user', 'educations', 'infos', 'bio'))->with(['title' => $user->username]);
 }
 public function postStudent(StudentRequest $request)
 {
     $user = new User();
     $user->username = $request->txtten;
     $user->password = Hash::make($request->txtten);
     $user->name = $request->txtten;
     $user->save();
     $user_id = $user->id;
     $permission = Permission::where('slug', 'student')->get()->first();
     $permissionUser = new PermissionUser();
     $permissionUser->permission_id = $permission->id;
     $permissionUser->user_id = $user_id;
     $permissionUser->save();
     $student = new ThiSinh();
     $student->ten = $request->txtten;
     $student->gioitinh = $request->sltGt;
     $student->namsinh = $request->txtns;
     $student->quequan = $request->txtqq;
     $student->khuvuc = $request->txtkv;
     $student->user_id = $user_id;
     $student->save();
     $thisinh_id = $student->id;
     $point = new Diem();
     $point->sbd = $request->txtsbd;
     $point->mon1 = 0;
     $point->mon2 = 0;
     $point->mon3 = 0;
     $point->khoi = $request->txtkt;
     $point->thisinh_id = $thisinh_id;
     $point->save();
     return redirect()->route('cluster-staff.quan-ly-thong-tin-thi-sinh.listStudent')->with(['flash_level' => 'success', 'flash_message' => 'Success!!! Complete Add Student']);
 }
Example #6
0
 public function findByUserNameOrCreate($userData)
 {
     $user = User::where('social_id', '=', $userData->id)->first();
     if (!$user) {
         $user = new User();
         $user->social_id = $userData->id;
         $user->email = $userData->email;
         $user->first_name = $userData->user['first_name'];
         $user->last_name = $userData->user['last_name'];
         $name = str_random(32);
         while (!User::where('avatar', '=', $name . '.jpg')->get()->isEmpty()) {
             $name = str_random(32);
         }
         $filename = $name . '.' . 'jpg';
         Image::make($userData->avatar_original)->fit(1024, 1024)->save(public_path() . '/avatars_large/' . $filename);
         Image::make(public_path() . '/avatars_large/' . $filename)->resize(200, 200)->save(public_path() . '/avatars/' . $filename);
         $user->avatar = $filename;
         $user->gender = $userData->user['gender'];
         $user->verified = $userData->user['verified'];
         $user->save();
         \Session::put('auth_photo', $filename);
     } else {
         $this->checkIfUserNeedsUpdating($userData, $user);
         \Session::put('auth_photo', $user->avatar);
     }
     return $user;
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = new User(['name' => $data['name'], 'email' => $data['email'], 'image' => $data['image'], 'password' => bcrypt($data['password'])]);
     $user->role = 'user';
     $user->save();
     return $user;
 }
Example #8
0
 /**
  * Determine if the given user can delete the given resume.
  *
  * @param User $user
  * @param Resume $resume
  *
  * @return bool
  */
 public function destroy(User $user, Resume $resume)
 {
     if ($user->canDo('career.resume.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $resume->user_id;
 }
Example #9
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = new User(['name' => $data['name'], 'last_name' => $data['last_name'], 'company' => $data['company'], 'number' => $data['number'], 'user' => $data['user'], 'password' => bcrypt($data['password']), 'email' => $data['email']]);
     $user->role = 'client';
     $user->save();
     return $user;
 }
Example #10
0
 /**
  * Determine if the given user can delete the given task.
  *
  * @param User $user
  * @param Task $task
  *
  * @return bool
  */
 public function destroy(User $user, Task $task)
 {
     if ($user->canDo('task.task.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $task->user_id;
 }
Example #11
0
 public function test()
 {
     $user = new User();
     $user->username = "test";
     $user->password = Hash::make("test");
     $user->save();
 }
Example #12
0
 /**
  * Determine if the given user can delete the given pricelist.
  *
  * @param User $user
  * @param PriceList $pricelist
  *
  * @return bool
  */
 public function destroy(User $user, PriceList $pricelist)
 {
     if ($user->canDo('pricelist.pricelist.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $pricelist->user_id;
 }
 public static function register(array $data)
 {
     // Fake when saving data
     $user = new User();
     $user->fill(['name' => trim($data['name']), 'email' => filter_var($data['email'], FILTER_SANITIZE_EMAIL), 'password' => $data['password']]);
     return $user;
 }
Example #14
0
 /**
  * Include comments.
  *
  * @param  \App\User                     $user
  * @param  \League\Fractal\ParamBag|null $params
  * @return  \League\Fractal\Resource\Collection
  * @throws  \Exception
  */
 public function includeComments(User $user, ParamBag $params = null)
 {
     $transformer = new \App\Transformers\CommentTransformer($params);
     $parsed = $this->getParsedParams();
     $comments = $user->comments()->limit($parsed['limit'])->offset($parsed['offset'])->orderBy($parsed['sort'], $parsed['order'])->get();
     return $this->collection($comments, $transformer);
 }
Example #15
0
 /**
  * Storing All Users Post
  * @return [type] [description]
  */
 public function UsersNewsFeed(NewsFeed $request, User $user)
 {
     //Ignore
     $newsFeed = $request->except('_token');
     //For NewsFeed
     $username = $request->input('UserPosting');
     $usernameUpdate = $request->input('UserNameBeingUpdated');
     //For Timelines
     $userID = $request->input('UserPostingID');
     // For Single User posting
     $id = Redis::incr('total_post_id');
     Redis::hset('list_post_id', $username, $id);
     Redis::lpush('newsFeed' . ':' . $username, json_encode($newsFeed));
     // Cross Users Posting
     if ($usernameUpdate == true) {
         Redis::lpush('newsFeed' . ':' . $usernameUpdate, json_encode($newsFeed));
     }
     /**
      * Minor Bug.
      * If someone (who you're not following) posts on your newsfeed it should also show up on your timeline also
      */
     // Timeline
     Redis::lpush('timeline' . ':' . $userID, json_encode($newsFeed));
     $faveID = $user->favoriteeList();
     // Users Following Timeline
     if ($faveID == true) {
         foreach ($faveID as $id) {
             Redis::lpush('timeline:' . $id, json_encode($newsFeed));
         }
     }
 }
Example #16
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $newUser = new User();
     $newUser->email = 'test@example.com';
     $newUser->password = Hash::make('password');
     $newUser->save();
 }
Example #17
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|string', 'email' => 'required|email|unique:users,email', 'twitter_username' => 'string', 'password' => 'required|confirmed|string', 'password_confirmation' => 'required|string']);
     if ($validator->fails()) {
         $httpStatus = 400;
         $outcome = 'no';
         $error = $validator->errors()->all();
     } else {
         $newuser = new User();
         $newuser->name = $request->name;
         $newuser->email = $request->email;
         $newuser->activateToken = uniqid();
         $newuser->twitter_username = !is_null($request->twitter_username) ? $request->twitter_username : "";
         $newuser->password = bcrypt($request->password);
         $newuser->save();
         Mail::send('emails.activate', ['user' => $newuser], function ($message) use($newuser) {
             $message->subject("Welcome, activate your account in Saveet");
             $message->to($newuser->email);
         });
         $httpStatus = 200;
         $outcome = 'yes';
         $error = '';
     }
     return response()->api($httpStatus, $outcome, $error, '');
 }
Example #18
0
 /**
  * Determine if the given user can delete the given settings.
  *
  * @param User $user
  * @param Settings $settings
  *
  * @return bool
  */
 public function destroy(User $user, Setting $settings)
 {
     if ($user->canDo('settings.setting.delete')) {
         return true;
     }
     return $user->id === $settings->user_id;
 }
Example #19
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(User $user)
 {
     $users = $user->getUsers(['Author', '3rd party content provider', 'Administrator', 'Publisher', 'Frontpage editor', 'Super Admin'], 'name|asc');
     $user_names = array();
     $i = 0;
     foreach ($users as $user) {
         foreach ($user->details as $u) {
             $user_names[$user->name] = $u->full_name;
         }
         $i++;
     }
     $users = array_name($user_names);
     $auth = Auth::user()->hasRole('Author', '') ? Auth::user()->name : null;
     $image_gallery = [['img' => null, 'title' => null, 'alt' => null, 'source' => null, 'author' => null, 'meta_desc' => null, 'meta_key' => null]];
     if (count(Session::get('_old_input')['image']) > 0) {
         $image_gallery = '';
         $image_gallery = add_image_array(Session::get('_old_input')['image']);
     }
     $checked_cats = '';
     $catid = '';
     $json_extra = '';
     if (count(Session::get('_old_input')['cat']) > 0) {
         $checked_cats = join(',', Session::get('_old_input')['cat']);
     }
     $extra_fields = '';
     if (count(Session::get('_old_input')['extra_fields']) > 0) {
         $extra_fields = Session::get('_old_input')['extra_fields'];
         $json_extra = json_encode($extra_fields);
     }
     $fields = hasFields([2], ['select' => ['col-sm' => 5], 'input' => ['col-sm' => 5], 'textarea' => ['col-sm' => 9]], $extra_fields);
     return view('admin.articles.create', compact('users', 'auth', 'fields', 'image_gallery', 'checked_cats', 'catid', 'json_extra', 'extra_fields'));
 }
Example #20
0
 private function save(User $user, array $inputs)
 {
     $user->name = $inputs['name'];
     $user->email = $inputs['email'];
     $user->admin = isset($inputs['admin']);
     $user->save();
 }
 public function store(Registration_validate $request)
 {
     $request->all();
     $User1 = new User(array('First_name' => $request->get('fn'), 'Last_name' => $request->get('ln'), 'Username' => $request->get('un'), 'password' => bcrypt($request->get('ps')), 'Mobile_number' => $request->get('mn')));
     $User1->save();
     return redirect('/Login');
 }
Example #22
0
 public function getSavepwd()
 {
     $u_id = Session::get('u_id');
     $model = new User();
     $info = $model->getUser_one("{$u_id}");
     if ($_POST['oldpwd'] == $info['pwd']) {
         if ($_POST['pwd1'] == $_POST['pwd2']) {
             //$res = DB::table('user')->where('_id',"$u_id")->update(['pwd' => "$_POST['pwd1']"]);
             if ($res) {
                 $result['code'] = 2;
                 $result['msg'] = '修改成功';
             } else {
                 $result['code'] = 3;
                 $result['msg'] = '修改失败';
             }
         } else {
             $result['code'] = 1;
             $result['msg'] = '两次密码不相同';
         }
     } else {
         $result['code'] = 0;
         $result['msg'] = '旧密码不正确';
     }
     print_r($result);
     die;
 }
Example #23
0
 public function refresh()
 {
     if (!\Session::get('user')->is_admin()) {
         abort(401);
     }
     $group_id = config('gapper.group_id');
     $members = Client::getMembers($group_id);
     if (count($members)) {
         $deleted_users = User::all()->lists('gapper_id', 'id')->toArray();
         foreach ($members as $member) {
             $id = $member['id'];
             $user = User::where('gapper_id', $id)->first();
             if (!$user) {
                 $user = new \App\User();
                 $user->gapper_id = $member['id'];
                 $user->name = $member['name'];
                 $user->icon = $member['icon'];
             } else {
                 $user->name = $member['name'];
                 $user->icon = $member['icon'];
                 //从 deleted_users 中删除当前 gapper_id 对应的用户
                 //最后剩下的, 就是 User 中不包含 gapper_id 的用户
                 if (array_key_exists($member['id'], $deleted_users)) {
                     unset($deleted_users[$id]);
                 }
             }
             $user->save();
         }
         //发现有需要删除的 User
         if (count($deleted_users)) {
             $to_deleted_users = User::whereIn('id', array_values($deleted_users))->delete();
         }
     }
     return redirect()->to('users')->with('message_content', '同步成功!')->with('message_type', 'info');
 }
 public function save(Request $request)
 {
     $input = $request->all();
     // $field_name = implode('|',$input['website']['locales']);
     $company = new Company();
     $company->name = $input['client']['company_name'];
     $company->alias = $input['website']['sub_name'];
     $company->save();
     $user = new User();
     $user->name = $input['client']['name'];
     $user->email = $input['client']['email'];
     $user->password = $input['client']['password'];
     $user->ip = '*';
     $user->branch_id = 1;
     $user->company_id = $company->id;
     $user->active = 1;
     $user->save();
     $user->roles()->attach(Role::find(1)->id);
     // $gr_fields = new GrFields;
     // $gr_fields->field_name = $field_name;
     // $gr_fields->company_id = $company->id;
     // $gr_fields->save();
     session(['input' => $input]);
     return redirect('thanks');
 }
Example #25
0
 public function run()
 {
     $user = new User();
     $user->id = 1;
     $user->username = 'admin';
     $user->save();
 }
Example #26
0
 /**
  * Determine if the given user can delete the given block.
  *
  * @param User $user
  * @param Block $block
  *
  * @return bool
  */
 public function destroy(User $user, Block $block)
 {
     if ($user->canDo('block.block.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $block->user_id;
 }
Example #27
0
 /**
  * Determine if the given user can delete the given category.
  *
  * @param User $user
  * @param Category $category
  *
  * @return bool
  */
 public function destroy(User $user, Category $category)
 {
     if ($user->canDo('forum.category.delete') && $user->is('admin')) {
         return true;
     }
     return $user->id === $category->user_id;
 }
Example #28
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $admin = new User();
     $admin->name = 'Henry Leon Gomez';
     $admin->email = 'helg18@gmail.com';
     $admin->password = bcrypt("henry");
     $admin->perfil = 'root';
     $admin->save();
     $accesos = new Accesos();
     $accesos->user_id = $admin->id;
     $accesos->create = 1;
     $accesos->read = 1;
     $accesos->update = 1;
     $accesos->delete = 1;
     for ($i = 0; $i < 25; $i++) {
         $usuario = new User();
         $faker = Faker\Factory::create();
         $usuario->name = $faker->name;
         $usuario->email = $faker->email;
         $usuario->password = bcrypt($faker->name);
         $usuario->perfil = 'usuario';
         $usuario->save();
         $accesos = new Accesos();
         $accesos->user_id = $usuario->id;
         $accesos->create = 0;
         $accesos->read = 0;
         $accesos->update = 0;
         $accesos->delete = 0;
     }
 }
 public function create(Request $data)
 {
     $validator = Validator::make($data->all(), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         $this->throwValidationException($data, $validator);
     }
     $user = new User();
     $activation_code = str_random(60) . $data['email'];
     $user->name = $data['name'];
     $user->email = $data['email'];
     $user->password = bcrypt($data['password']);
     $user->how_know = $data['how_know'];
     $user->activation_code = $activation_code;
     if ($user->save()) {
         $to = $data['email'];
         // subject
         $subject = 'Verification Required';
         // message
         $message = "\n\t\t\t\t<div style='line-height:1'>\n\t\t\t\t\t<div style='width:700px;margin:0 auto;margin-top:20px;padding:0px;background:#f5f5f5;border:1px solid #d2d2d2;border-radius:5px;font-family:Arial,Helvetica,sans-serif'>\n\t\t\t\t\t<div style='width:700px;margin:0px;padding:20px 0px 20px 0px;background:url(https://ci4.googleusercontent.com/proxy/U9DVvzyQQifr6SPalG_Od_DoppU3VoTGQ_PsL0zGu6CNvmYzsnGQ6kaGbuRdwluMALk7IZCWqMOxM-XtCO772qA7_Zqx=s0-d-e1-ft#{{url('images/logo.png')}}) top left repeat;border-radius:5px 5px 0px 0px;text-align:center'><img src='{{url('images/logo.png')}}' ></div>\n\t\t\t\t\t    <div style='width:660px;margin:10px 0px 0px 0px;padding:20px;font-size:12px;color:#262626;line-height:18px'>\n\t\t\t\t\t    \t<p>Dear  <a href='mailto:premsingh57@gmail.com' target='_blank'>premsingh57@gmail.com</a>,</p>\n\t\t\t\t\t        <p>You are receiving this email because you are requested to  create new account on Omni Text Solution. Please click on the link below to complete your confirmation.</p>\n\n\t\t\t\t\t\t\t<div style='text-align:center;padding:10px 0px'><a style='font-size:14px;font-weight:bold;color:#fff;background:#2dcc70;text-decoration:none;border-radius:5px;padding:8px 15px' target='_blank'>Confirm</a></div>\n\n\t\t\t\t\t\t\t<p>If you think that you shouldn't have received this email, you can safely ignore it.</p>\n\n\t\t\t\t\t\t\t<p>Thank you,</p>\n\t\t\t\t\t\t\t<p>Omni Text Solution</p><div></div><div >\n\t\t\t\t\t    \t\n\t\t\t\t\t    </div></div></div>\n\t\t\t\t</div>\n\t\t\t";
         // To send HTML mail, the Content-type header must be set
         $headers = 'MIME-Version: 1.0' . "\r\n";
         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
         $headers .= "From: donotreply@omnitext.com" . "\r\n";
         mail($to, $subject, $message, $headers);
         \Session::flash('success_message', "Activation link is send to {$data['email']}. Please activite your account");
         return view('auth.register');
     }
 }
Example #30
0
 public function login_post()
 {
     $email = Input::get('email');
     $password = Input::get('password');
     // find user
     $user = User::findEmail($email)->first();
     //
     if ($user) {
         Auth::login($user);
         return redirect()->intended('web.me');
     } else {
         $user = new User();
         $user->name = $email;
         $user->email = $email;
         $user->password = $password;
         if (!$user->save()) {
             return redirect()->back()->withInput()->withErrors($user->getErrors());
         } else {
             Auth::login($user);
             if (Session::has('redirect')) {
                 $redirect = Session::get('redirect', route('web.home'));
                 Session::remove('redirect');
                 return redirect()->to($redirect);
             } else {
                 return redirect()->route('web.home');
             }
             return redirect()->route('web.me.profile.edit');
         }
     }
 }