Пример #1
0
 public function getLogin($social)
 {
     try {
         switch ($social) {
             case 'facebook':
                 $su = \Social::facebook('user');
                 break;
             case 'google':
                 $su = \Social::google('user');
                 break;
             default:
                 $su = null;
         }
         if ($su === null) {
             return \Redirect::route('frontend.index');
         }
         $m = \Member::where('uid', '=', $su->id)->where('social', '=', $social)->first();
         if ($m == null) {
             $m = new \Member();
             $m->uid = $su->id;
             $m->social = $social;
             $m->name = $su->name;
             $m->email = $su->email;
             if ($social == 'facebook') {
                 if (isset($su->birthday)) {
                     $m->birthday = date('Y-m-d', strtotime($su->birthday));
                 }
                 if (isset($su->gender)) {
                     $m->gender = substr($su->gender, 0, 1);
                 }
             }
             $m->save();
         }
         // register user into Auth that is a global variable
         \Auth::login($m);
         return \Redirect::route('frontend.index');
     } catch (Exception $e) {
         echo $e->getMessage();
         exit;
     }
 }
Пример #2
0
<?php

/*-----------------------------------------------------------------------------------
File contains the Google signin + after signin close window
-------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------
START Google signin process
-------------------------------------------------------------------------------------*/
require 'google.php';
$GOOGLE = new Social();
if (isset($_GET['google'])) {
    $GOOGLE->google();
}
?>
<!-- after authentication close the popup -->
<script type="text/javascript">
window.close();
</script>

<?php 
/*-----------------------------------------------------------------------------------
END Google signin
-------------------------------------------------------------------------------------*/