File: StaticUserStore.php

package info (click to toggle)
bamboo 1.2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 580 kB
  • ctags: 1,338
  • sloc: php: 4,061; makefile: 44; sh: 36
file content (45 lines) | stat: -rw-r--r-- 807 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

/*

StaticUserStore

A very simple user storage backend which allows a single user
to be hardcoded in the b.site file:

   userbackend = static, myuser:mypassword

*/

$base = dirname(dirname(__FILE__));
require_once("$base/UserStore.php");

class StaticUserStore extends UserStore {

var $user;
var $pass;

function StaticUserStore($args) {
	list($this->user,$this->pass) = explode(":",$args);
}

function authenticate($user,$pass,&$error) {
	$seed = preg_replace('/^\$.\$(.*)\$.*$/','$1',$this->pass);
	$hash_pass = crypt($pass,'$1$'.$seed);

	if ($user == $this->user && $pass == $this->pass) {
		return true;
	}
	elseif ($user == $this->user && $hash_pass == $this->pass) {
		return true;
	}
	else {
		$error = _("User or password is incorrect");
		return false;
	}
}

} // end class

return;
?>