예제 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['nickname' => 'required', 'content' => 'required']);
     if (Comment::where('id', $id)->update(Input::except(['_method', '_token']))) {
         return Redirect::to('admin/comments');
     } else {
         return Redirec::back()->withInput()->withErrors("更新失败");
     }
 }
예제 #2
0
 public function postAuth()
 {
     $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'), 'type' => 'associate');
     $course = Courses::find(Input::get('course'));
     if (Auth::user()->attempt($credentials)) {
         if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) {
             return Redirect::to(self::$route . '/acusado');
         } else {
             return Redirect::to(self::$route . '/pagamento');
         }
     } else {
         $associate = Associates::getByEmail($credentials['email']);
         if (!empty($associate[0])) {
             $associate = $associate[0];
             if ($associate->password == md5($credentials['password'])) {
                 $user_finded = User::where('email', '=', $credentials['email'])->take(1)->get();
                 $user = null;
                 if (!empty($user_finded[0])) {
                     $user = $user_finded[0];
                     $user->password = Hash::make($credentials['password']);
                     $user->save();
                 } else {
                     $user = new User();
                     $user->email = $associate->email;
                     if ($associate->nombre_completo != null) {
                         $user->name = $associate->nombre_completo;
                     } else {
                         $user->name = "User without name";
                     }
                     $user->status = 'publish';
                     $user->type = 'associate';
                     $user->password = Hash::make($credentials['password']);
                     $user->save();
                     $associate->user = $user->id;
                     $associate->save();
                 }
                 Auth::user()->login($user);
                 if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) {
                     return Redirect::to(self::$route . '/acusado');
                 } else {
                     return Redirect::to(self::$route . '/pagamento');
                 }
             } else {
                 $associate = ORGAssociates::getByEmail($credentials['email']);
                 if (!empty($associate[0])) {
                     $associate = $associate[0];
                     if ($associate->senha == md5($credentials['password'])) {
                         $user = new User();
                         $user->email = $associate->email;
                         if ($associate->nombre_completo != null) {
                             $user->name = $associate->nombre_completo;
                         } else {
                             $user->name = "User without name";
                         }
                         $user->status = 'publish';
                         $user->type = 'associate';
                         $user->password = Hash::make($credentials['password']);
                         $user->save();
                         $assoc = new Associates();
                         $assoc->associate = $associate->id_asociado;
                         $assoc->user = $user->id;
                         $assoc->email = $associate->email;
                         if ($associate->nombre_completo != null) {
                             $assoc->name = $associate->nombre_completo;
                         } else {
                             $assoc->name = "User without name";
                         }
                         $assoc->cpf = $associate->cpf;
                         $assoc->password = $associate->senha;
                         $assoc->status = 'publish';
                         $assoc->type = 'associate';
                         $assoc->save();
                         Auth::user()->login($user);
                         if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) {
                             return Redirect::to(self::$route . '/acusado');
                         } else {
                             return Redirect::to(self::$route . '/pagamento');
                         }
                     } else {
                         return Redirec::to(self::$route . '/error');
                     }
                 } else {
                     return Redirec::to(self::$route . '/error');
                 }
                 return Redirec::to(self::$route . '/error');
             }
         } else {
             $associate = ORGAssociates::getByEmail($credentials['email']);
             if (!empty($associate[0])) {
                 $associate = $associate[0];
                 if ($associate->senha == md5($credentials['password'])) {
                     $user = new User();
                     $user->email = $associate->email;
                     if ($associate->nombre_completo != null) {
                         $user->name = $associate->nombre_completo;
                     } else {
                         $user->name = "User without name";
                     }
                     $user->status = 'publish';
                     $user->type = 'associate';
                     $user->password = Hash::make($credentials['password']);
                     $user->save();
                     $assoc = new Associates();
                     $assoc->associate = $associate->id_asociado;
                     $assoc->user = $user->id;
                     $assoc->email = $associate->email;
                     if ($associate->nombre_completo != null) {
                         $assoc->name = $associate->nombre_completo;
                     } else {
                         $assoc->name = "User without name";
                     }
                     $assoc->cpf = $associate->cpf;
                     $assoc->password = $associate->senha;
                     $assoc->status = 'publish';
                     $assoc->type = 'associate';
                     $assoc->save();
                     Auth::user()->login($user);
                     if ($payment = ORGAssociateAnnuities::hasAnnuity(Auth::user()->user())) {
                         return Redirect::to(self::$route . '/acusado');
                     } else {
                         return Redirect::to(self::$route . '/pagamento');
                     }
                 } else {
                     return Redirec::to(self::$route . '/error');
                 }
             } else {
                 return Redirec::to(self::$route . '/error');
             }
         }
     }
 }
예제 #3
0
*/
Route::filter('guest', function () {
    if (Auth::check()) {
        return Redirect::to('/');
    }
});
/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
    if (Session::token() != Input::get('_token')) {
        throw new Illuminate\Session\TokenMismatchException();
    }
});
Route::filter('no_xhr', function () {
    if (Request::ajax()) {
        return Response::json("Bad request", 400);
    }
});
Route::filter('only_xhr', function () {
    if (!Request::ajax()) {
        return Redirec::back()->with('notification:error', 'Access denied.');
    }
});
 public function verify_email($code)
 {
     try {
         $user = User::where('activation_code', '=', $code)->first();
         if ($user == null) {
             echo "Invalide verfication code";
             return;
         } elseif ($user->activated == 1) {
             return Redirec::route('myprofile');
         }
         $user->activated = 1;
         $user->save();
         $id = $user->id;
         Auth::login($user);
         //verify success and login user
         //create a profile record for this new user
         $profile = UserProfile::firstOrNew(array('id' => $id));
         $financial = FinancialProfile::firstOrNew(array('user_id' => $id));
         $profile->save();
         $financial->save();
         /*DB::table('users')
         			-> where('activation_code',$code)
         			-> update(array('activated'=>1));
         		}catch(Exception $e) {
         			echo $e -> getMessage();
         		}*/
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     return Redirect::route('editProfile');
 }