Example #1
0
 /**
  * prepare the configuration
  *
  * @return void
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     CCConfig::create('auth')->_data = CCConfig::create('Core::phpunit/auth')->_data;
     $user = new Auth\User();
     $user->email = "*****@*****.**";
     $user->password = "******";
     $user->save();
     static::$current_user = $user;
 }
Example #2
0
 public function logout()
 {
     if ($_SERVER["REQUEST_METHOD"] !== "POST") {
         // Method Not Allowed
         http_response_code(405);
         header("Allow: POST");
         $this->setFieldError("main", "Method Not Allowed");
         return;
     }
     setcookie("sid", "");
     $user = new Auth\User();
     $user->logout();
     $this->setResponse("redirect", ".");
     $this->status = "ok";
 }
Example #3
0
File: ajax.php Project: Torredo/jew
 public function register()
 {
     if ($_SERVER["REQUEST_METHOD"] !== "POST") {
         // Method Not Allowed
         http_response_code(405);
         header("Allow: POST");
         $this->setFieldError("main", "Method Not Allowed");
         return;
     }
     setcookie("sid", "");
     $username = $this->getRequestParam("username");
     $password1 = $this->getRequestParam("password1");
     $password2 = $this->getRequestParam("password2");
     if (empty($username)) {
         $this->setFieldError("username", "Enter the username");
         return;
     }
     if (empty($password1)) {
         $this->setFieldError("password1", "Enter the password");
         return;
     }
     if (empty($password2)) {
         $this->setFieldError("password2", "Confirm the password");
         return;
     }
     if ($password1 !== $password2) {
         $this->setFieldError("password2", "Confirm password is not match");
         return;
     }
     $user = new Auth\User();
     try {
         $new_user_id = $user->create($username, $password1);
     } catch (\Exception $e) {
         $this->setFieldError("username", $e->getMessage());
         return;
     }
     $user->authorize($username, $password1);
     $this->message = sprintf("Hello, %s! Thank you for registration.", $username);
     $this->setResponse("redirect", "callback.php");
     $this->status = "ok";
 }
Example #4
0
<?php

if (!empty($_COOKIE['sid'])) {
    session_id($_COOKIE['sid']);
}
session_start();
require_once 'classes/Auth.class.php';
if (Auth\User::isAuthorized()) {
    header("Location: kurs.php");
} else {
    ?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Authorization</title>
    <?php 
    include "view/css.php";
    ?>
  </head>

  <body>
<div class="app app-header-fixed  ">
    <div class="container w-xxl w-auto-xs">
      <form class="form-signin ajax" method="post" action="./ajax.php">
        <div class="main-error alert alert-error hide"></div>

        <h2 class="form-signin-heading">Вход в админку</h2>
        <input name="username" type="text" class="input-block-level form-control m-b" placeholder="Логин" autofocus>
        <input name="password" type="password" class="input-block-level form-control m-b" placeholder="Пароль">
        <label class="checkbox m-l-md">
Example #5
0
if (!Is::app('PHPfox_FeaturedUsers')) {
    return false;
}
new Payment\Event('featured-users', function (\Core\Payment\Object $payment) {
    $payment->log('Event touchdown...');
    if ($payment->success()) {
        $payment->log('Setting user "' . $payment->item_number . '" to be featured.');
        $db = new Db();
        $cache = new Cache();
        try {
            $user = (new \Api\User())->get($payment->item_number);
            $total = (int) $db->select('*')->from(':user_featured')->count();
            $total++;
            $db->delete(':user_featured', ['user_id' => $user->id]);
            $db->insert(':user_featured', ['user_id' => $user->id, 'ordering' => $total]);
            $cache->del('featured_users');
        } catch (\Exception $e) {
            $payment->log($e->getMessage());
        }
    }
});
new Route('/featured-users/thanks', function (Controller $controller) {
    return $controller->render('thanks.html');
});
new Route('/featured-users/pay', function (Controller $controller) {
    $auth = new Auth\User();
    $auth->membersOnly();
    $controller->h1(_p('Get Featured'), '');
    return $controller->render('pay.html');
});