Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshartig committed May 29, 2014
0 parents commit 9d8f915
Show file tree
Hide file tree
Showing 14 changed files with 1,388 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.php
2 changes: 2 additions & 0 deletions lib/Auth/Custom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
42 changes: 42 additions & 0 deletions lib/Auth/SessionAuth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

class Auth_SessionAuth implements Auth_Template
{
public function start($sessionID, $userIDKey = 'userID', $cookieName = 'TRNSSESS')
{
if (session_id() == "") {
if (!empty($sessionID)) {
session_id($sessionID);
}
if (isset($config['cookieName'])) {
ini_set('session.name', $config['cookieName']);
}
session_start();
}
if (!isset($config['userIDKey'])) {
throw new Exception("TranslationAuth cannot load userID from session without a specified userIDKey!");
}
$user = array('userID' => null,
'username' => null,
);
$key = $config['userIDKey'];
if (isset($_SESSION[$key])) {
$user['userID'] = $_SESSION[$key];
}
return $user;
}

public function login($username, $password)
{
$db = TranslationDB::getInstance();
//todo: login?
}

public function logout()
{
session_destroy();
return true;
}
}

//EOF
25 changes: 25 additions & 0 deletions lib/Auth/Template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

interface Auth_Template
{
public function __construct();

/**
* @return array (userID => int|string, username => string)
*/
public function start($sessionID);

/**
* $password is NOT hashed
*
* @return array (userID => int|string, username => string)
*/
public function login($username, $password);

/**
* @return bool success
*/
public function logout();
}

//EOF
2 changes: 2 additions & 0 deletions lib/DB/Custom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Loading

0 comments on commit 9d8f915

Please sign in to comment.