예제 #1
0
파일: User.php 프로젝트: rjha/sc
 function ban($loginId)
 {
     // session Id for this user?
     $loginRow = mysql\Login::getOnId($loginId);
     $sessionId = $loginRow["session_id"];
     mysql\User::set_bu_bit($loginId, 1, $sessionId);
 }
예제 #2
0
파일: Login.php 프로젝트: rjha/sc
 function getAggregate()
 {
     $rows = mysql\Login::getAggregate();
     return $rows;
 }
예제 #3
0
파일: twitter.php 프로젝트: rjha/sc
function processUser($connection)
{
    $user_info = $connection->get('account/verify_credentials');
    if (isset($user_info->error)) {
        $message = "Error retrieving twitter user information";
        Logger::getInstance()->error($message);
        raiseUIError();
    } else {
        // get screenName, profile Pic
        // exisitng record ? find on twitter_id
        // New record - create login + twitter record
        // start login session
        $id = $user_info->id;
        if (empty($id)) {
            trigger_error("Could not retrieve twitter id : please try again.", E_USER_ERROR);
        }
        $image = $user_info->profile_image_url;
        $screenName = $user_info->screen_name;
        $name = $user_info->name;
        $location = $user_info->location;
        // do not know what twitter will return
        // we consider auth to be good enough for a user
        if (empty($name) && empty($screenName)) {
            $name = "Anonymous";
        }
        $message = sprintf("Login:Twitter :: id %d ,name %s ", $id, $name);
        Logger::getInstance()->info($message);
        $twitterDao = new \com\indigloo\sc\dao\Twitter();
        $loginId = $twitterDao->getOrCreate($id, $name, $screenName, $location, $image);
        if (empty($loginId)) {
            $message = "Not able to create 3mik login for twitter user";
            Logger::getInstance()->error($message);
            raiseUIError();
        }
        //success - update login record
        // start 3mik session
        $remoteIp = \com\indigloo\Url::getRemoteIp();
        mysql\Login::updateIp(session_id(), $loginId, $remoteIp);
        $code = Login::startOAuth2Session($loginId, Login::TWITTER);
        $location = $code == Login::FORBIDDEN_CODE ? AppConstants::ERROR_403_URL : AppConstants::DASHBOARD_URL;
        header("Location: " . $location);
    }
}
예제 #4
0
파일: fb2.php 프로젝트: rjha/sc
/**
 * 
 * @param access_token - access token returned by facebook for offline use
 * @param expires - time in seconds till the access_token expiry  
 * 
 * 
 */
function processUser($user, $access_token, $expires)
{
    // exisitng record ? find on facebook_id
    // New record - create login + facebook record
    // start login session
    $id = $user->id;
    if (empty($id)) {
        trigger_error("Could not retrieve facebook id : please try again.", E_USER_ERROR);
    }
    //rest of the properties may be missing
    $email = property_exists($user, 'email') ? $user->email : '';
    $name = property_exists($user, 'name') ? $user->name : '';
    $firstName = property_exists($user, 'first_name') ? $user->first_name : '';
    $lastName = property_exists($user, 'last_name') ? $user->last_name : '';
    $link = property_exists($user, 'link') ? $user->link : '';
    $gender = property_exists($user, 'gender') ? $user->gender : '';
    // do not know what facebook will return
    // we consider auth to be good enough for a user
    if (empty($name) && empty($firstName)) {
        $name = "Anonymous";
    }
    $message = sprintf("Login:Facebook :: id %d ,email %s ", $id, $email);
    Logger::getInstance()->info($message);
    $facebookDao = new \com\indigloo\sc\dao\Facebook();
    $loginId = $facebookDao->getOrCreate($id, $name, $firstName, $lastName, $link, $gender, $email, $access_token, $expires);
    if (empty($loginId)) {
        $message = "Not able to create 3mik login for facebook user";
        Logger::getInstance()->error($message);
        raiseUIError();
    }
    //success - update login record
    // start 3mik session
    $remoteIp = \com\indigloo\Url::getRemoteIp();
    mysql\Login::updateTokenIp(session_id(), $loginId, $access_token, $expires, $remoteIp);
    $code = Login::startOAuth2Session($loginId, Login::FACEBOOK);
    $location = $code == Login::FORBIDDEN_CODE ? AppConstants::ERROR_403_URL : AppConstants::DASHBOARD_URL;
    header("Location: " . $location);
}
예제 #5
0
파일: register.php 프로젝트: rjha/sc
     } catch (\Exception $ex) {
         $code = $ex->getCode();
         switch ($code) {
             case 401:
                 $message = "Wrong login or password. Please try again!";
                 throw new UIException(array($message));
                 break;
             default:
                 $message = "Error during login. Please try after some time!";
                 throw new UIException(array($message));
         }
     }
     //success - update login record
     // start 3mik session
     $remoteIp = \com\indigloo\Url::getRemoteIp();
     mysql\Login::updateIp(session_id(), $loginId, $remoteIp);
     Login::startOAuth2Session($loginId, Login::MIK);
     //add overlay message
     $message = "success! Thanks for joining " . $fvalues['first_name'];
     $gWeb->store("global.overlay.message", $message);
     header("Location: " . AppConstants::DASHBOARD_URL);
     exit;
 } catch (UIException $ex) {
     $gWeb->store(Constants::STICKY_MAP, $fvalues);
     $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());
     header("Location: " . $fUrl);
     exit(1);
 } catch (DBException $ex) {
     $gWeb->store(Constants::STICKY_MAP, $fvalues);
     // @imp: this is mysql error code
     // @todo need to define this as a constant
예제 #6
0
파일: google2.php 프로젝트: rjha/sc
function processUser($user)
{
    $id = $user->id;
    if (empty($id)) {
        trigger_error("Could not retrieve google id : please try again.", E_USER_ERROR);
    }
    //rest of the properties may be missing
    $email = property_exists($user, 'email') ? $user->email : '';
    $name = property_exists($user, 'name') ? $user->name : '';
    $firstName = property_exists($user, 'given_name') ? $user->given_name : '';
    $lastName = property_exists($user, 'family_name') ? $user->family_name : '';
    $photo = property_exists($user, 'picture') ? $user->picture : '';
    // we consider id + auth to be good enough for a user
    if (empty($name) && empty($firstName)) {
        $name = "Anonymous";
    }
    $message = sprintf("Login:Google :: id %d ,email %s ", $id, $email);
    Logger::getInstance()->info($message);
    $googleDao = new \com\indigloo\sc\dao\Google();
    $loginId = $googleDao->getOrCreate($id, $email, $name, $firstName, $lastName, $photo);
    if (empty($loginId)) {
        $message = "Not able to create 3mik login for google user";
        Logger::getInstance()->error($message);
        raiseUIError();
    }
    //success - update login record
    // start 3mik session
    $remoteIp = \com\indigloo\Url::getRemoteIp();
    mysql\Login::updateIp(session_id(), $loginId, $remoteIp);
    $code = Login::startOAuth2Session($loginId, Login::GOOGLE);
    $location = $code == Login::FORBIDDEN_CODE ? AppConstants::ERROR_403_URL : AppConstants::DASHBOARD_URL;
    header("Location: " . $location);
}