summaryrefslogtreecommitdiffstats
path: root/generated-classes/User.php
blob: 0602db9e442eb90d5988c9c6c2a4d179ba704ad6 (plain)
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
<?php

use Base\User as BaseUser;

/**
 * Skeleton subclass for representing a row from the 'user' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 */
class User extends BaseUser
{
	public function setPassword($v)
	{
		if(parent::getSalt() == null)
		{
			parent::setSalt(md5(uniqid(rand(), true), 0, 20));
		}
		return parent::setPassword(self::createHash($v));
	}
	
	public function checkPassword($v)
	{
		if(parent::getSalt() == null)
		{
			return false;
		}
		
		return self::createHash($v) == parent::getPassword();
	}
	
	private function createHash($v)
	{
		return sha1(parent::getSalt() . $v);
	}
}