Esempio n. 1
0
 public function login()
 {
     if ($this->check_session()) {
         return true;
     }
     $restTransportInstance = new \RestTransport(\Config::get('yousendit.host'), \Config::get('yousendit.api_key'));
     \Session::set('ysi.sTr', $restTransportInstance);
     $authInstance = new \Authentication(\Config::get('yousendit.host'), \Config::get('yousendit.api_key'), \Session::get('ysi.sTr'));
     $auth = $authInstance->login(\Config::get('yousendit.email'), \Config::get('yousendit.password'));
     $errorStatus = $auth->getErrorStatus();
     $token = $auth->getAuthToken();
     if (!empty($errorStatus)) {
         $this->errorcode = $errorStatus->getMessage();
         $this->errormessage = $errorStatus->getCode();
         return false;
     } else {
         if (empty($token)) {
             $this->errormessage = 'Invalid apikey or hostname!';
             return false;
         } else {
             \Session::set('ysi.sEmail', \Config::get('yousendit.email'));
             \Session::set('ysi.sPass', \Config::get('yousendit.password'));
             \Session::set('ysi.sToken', $token);
             \Session::set('ysi.sApp', \Config::get('yousendit.api_key'));
             \Session::set('ysi.sHost', \Config::get('yousendit.host'));
             \Session::set('ysi.sUserAgent', 'we');
             return true;
         }
     }
     return false;
 }
 protected function _run($request)
 {
     if ($this->requestMethod == 'POST' && count($request) == 0) {
         // User tries to login
         Authentication::login($_POST['username'], $_POST['password']);
         if (!Authentication::authenticated()) {
             Headers::sendStatusUnauthorized();
             return;
         } else {
             Headers::sendStatusOk();
             echo "login succeeded<br>";
             return;
         }
     } else {
         Authentication::authenticate();
         if (!Authentication::authenticated()) {
             Headers::sendStatusUnauthorized();
             return;
         }
         if ($this->requestMethod == 'GET' && count($request) > 0) {
             // User info requested
             echo "requesting userinfo of user " . $request[0];
         } else {
             // Bad request
             Headers::sendStatusMethodNotAllowed();
             echo "Method not allowed<br>";
             print_r($request);
         }
     }
 }
Esempio n. 3
0
 public function loginAction()
 {
     $username = $this->_getParam('username');
     $password = $this->_getParam('password');
     if (!isset($username) or !isset($password)) {
         $auth = new Authentication();
         $auth->logout();
     }
     $auth = new Authentication();
     if ($auth->login($username, $password)) {
         // we have a valid login
         $this->_redirect('/');
     } else {
         // not valid
         $this->_redirect('/');
     }
     //end login action
 }
Esempio n. 4
0
<?php

require_once '../includes/base.inc.php';
$auth = new Authentication();
if (isset($_POST['username'], $_POST['password'])) {
    $login = $auth->login($_POST['username'], $_POST['password']);
    if ($login) {
        header('Location: index.php');
    }
    $smarty->assign('error', 'Invalid username or password');
}
$smarty->display('_header.tpl');
$smarty->display('login.tpl');
$smarty->display('_footer.tpl');
<?php

/*
 * Copyright 2011 Martin Nordholts <*****@*****.**>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// FIXME: Use a host that better supports PHP include paths...
set_include_path(get_include_path() . PATH_SEPARATOR . '/customers/tasktaste.com/tasktaste.com/httpd.www/phpincludes');
require_once 'TaskTaste/tasktaste.php';
$username = Utils::get_name_from_post(USERNAME);
$password = Utils::get_name_from_post(PASSWORD);
$remeber_login = Utils::get_name_from_post(REMEMBER_LOGIN);
$authentication_result = Authentication::login($username, $password, $remeber_login);
Utils::output_ajax_result($authentication_result);
        $email_value = $flash['email'];
    }
    $app->render('\\Authentication\\Login.php', array('error' => $error, 'email_value' => $email_value, 'urlRedirect' => $urlRedirect));
});
$app->post("/login", function () use($app) {
    $email = $app->request()->post('email');
    $password = $app->request()->post('password');
    $errors = array();
    $auth = new Authentication($app->request()->post('email'), $app->request()->post('password'));
    //if username or password is empty
    if ($auth->isEmpty()) {
        $_SESSION['urlRedirect'] = $app->request()->getPathInfo();
        $app->flash('error', 'Email and password required');
        $app->redirect('/login');
    } else {
        if (!$auth->login()) {
            $app->flash('email', $email);
            $app->flash('error', $auth->getError());
            $app->redirect('/login');
        }
    }
    //success! Set the following properties
    $_SESSION['user'] = $email;
    if (isset($_SESSION['urlRedirect'])) {
        $tmp = $_SESSION['urlRedirect'];
        unset($_SESSION['urlRedirect']);
        $app->redirect($tmp);
    }
    $app->redirect('/');
});
$app->get("/create/new/user", function () use($app) {
Esempio n. 7
0
<?php

/*
 * Copyright 2011 Martin Nordholts <*****@*****.**>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
// FIXME: Use a host that better supports PHP include paths...
set_include_path(get_include_path() . PATH_SEPARATOR . '/customers/tasktaste.com/tasktaste.com/httpd.www/phpincludes');
require_once 'TaskTaste/tasktaste.php';
$username = Utils::get_name_from_post(NEW_USERNAME);
$password = Utils::get_name_from_post(NEW_PASSWORD);
$email = Utils::get_name_from_post(NEW_EMAIL);
// Create user
$user = Sql::create_user($username, $password, $email);
// Log him in
$logged_in = FALSE;
if ($user) {
    $logged_in = Authentication::login($username, $password, TRUE);
}
Utils::output_ajax_result($user);
Esempio n. 8
0
<?php

session_start();
//echo $_SESSION['User_ID'];
$login = $_POST['login'];
$password = $_POST['password'];
include_once 'moacl_framework.php';
$auth = new Authentication();
if ($auth->authorizer() or $auth->login($login, $password, "gag@gag")) {
    //уже авторизован или правлиьный пароль и логин
    require_once 'main_access.php';
} else {
    //require_once 'access_denied.php'
    header("Location: access_denied.php");
    exit;
}
Esempio n. 9
0
require_once './include/RestTransport.php';
require_once './include/ResponseEntities.php';
include_once './header.html';
session_start();
if (isset($_POST['submitted'])) {
    $apikey = trim($_POST['apikey'], " ");
    $_SESSION['sApp'] = $apikey;
    $host = $_POST['endpoint'];
    $_SESSION['sHost'] = $host;
    $_SESSION['sUserAgent'] = $_POST['useragent'];
    $restTransportInstance = new RestTransport($host, $apikey);
    $_SESSION['sTr'] = $restTransportInstance;
    $email = trim($_POST['email'], " ");
    $password = trim($_POST['password'], " ");
    $auth = new Authentication($_SESSION['sHost'], $_SESSION['sApp'], $_SESSION['sTr']);
    $responseObject = $auth->login($email, $password);
    $errorStatus = $responseObject->getErrorStatus();
    $token = $responseObject->getAuthToken();
    if (!empty($errorStatus)) {
        echo '<font color="red">' . "Error: " . $errorStatus->getMessage() . '</font><br>';
    } else {
        if (empty($token)) {
            echo '<font color="red">' . "Error: invalid apikey or hostname!" . '</font><br>';
        } else {
            $_SESSION['sEmail'] = $email;
            $_SESSION['sPass'] = $password;
            $_SESSION['sToken'] = $responseObject->getAuthToken();
            header('Location: ./Actions.php');
        }
    }
}
Esempio n. 10
0
use LoginRadiusSDK\LoginRadius;
//load up your config file
include_once 'config.php';
require_once __DIR__ . '/classes/authentication.php';
ob_start();
$post_value = $_POST;
// If user is logged in then redirect to profile page.
if (isset($_SESSION['user_id'])) {
    header("Location: profile.php");
    exit;
}
//Handle LoginRadius token and provide login to user.
if (isset($post_value['token']) && $post_value['token'] != '') {
    //Call login constructor
    Authentication::getProfiles();
    Authentication::login();
}
//Load scripts
include_once 'includes/header.php';
?>
<!-- Add Page content here-->
<div class="lr-frame lr-input-style">
    <h2>A Complete User Authentication Solution </h2>

    <div style="  text-align: left;margin-top:20px;">
        Want to offer your users a choice between Social Login and Traditional Registration?
        We offer both, so you can manage all of your authentication systems in one place. LoginRadius Customer Registration
        and Social Login solutions work seamlessly together for a simplified registration system.
    </div>
    <div style="  text-align: left;margin-top:20px;">
        <h3>1. Managed Registration Service</h3>
Esempio n. 11
0
<?php

require_once '../lib/bootstrap.inc';
// -----------------------------------------------------------------------------
// Logging in
// -----------------------------------------------------------------------------
// Already logged in?
if (Authentication::current_user() !== false) {
    Util::redirect(@$_REQUEST['redirect']);
}
// Try to log in
if (isset($_REQUEST['login'], $_REQUEST['password'])) {
    try {
        Authentication::login($_REQUEST['login'], $_REQUEST['password']);
        Util::redirect(@$_REQUEST['redirect']);
    } catch (InternalException $e) {
        ErrorPage::die_fancy($e);
    } catch (Exception $e) {
        Template::add_message('login', 'error', "Incorrect username or password.");
        Log::info("Login failed for username '" . $_REQUEST['login'] . "'");
    }
}
// -----------------------------------------------------------------------------
// Login page
// -----------------------------------------------------------------------------
class View extends Template
{
    function title()
    {
        return "Log in";
    }
Esempio n. 12
0
 function login($login, $password, $email)
 {
     self::$login = $login;
     self::$password = $password;
     self::$email = $email;
     self::prepareRegData();
     $query = "SELECT `Password`, `Salt`, `Login`, `User_ID` FROM `users` WHERE `Login`= '{$login}'  and `Activation` = 1 and `Deleted` = 0;";
     $result = self::$mysqli->query($query) or die(self::$mysqli->error);
     $row = $result->fetch_array(MYSQLI_ASSOC);
     $_USER = $row;
     $password_db = $row['Password'];
     $salt_db = $row['Salt'];
     $login_db = $row['Login'];
     $hash = crypt(self::$password, $salt_db);
     $user_id = $row['User_ID'];
     if ($hash == $password_db && ($login = $login_db)) {
         $_SESSION = array_merge($_SESSION, $_USER);
         //Добавляем массив с пользователем к массиву сессии
         $query = "UPDATE `users` SET `SID`='" . SID . "' WHERE `User_ID`='{$user_id}';";
         //примерный запрос для ддълогирования действия аутентификации $query = "INSERT INTO `users_sessions`
         // (`SID`, `UID`, `IP`, `BROWSER`, `Action_ID`, `Date_of_start` ,`Date_of_end`) VALUES
         // ('$sid' , '$uid' ,'$ip', '$browser', 1 , Now() , Now());"; // Action_ID =1 (registration)
         self::$mysqli->query($query) or die(self::$mysqli->error);
         return true;
     } else {
         return false;
     }
 }