示例#1
0
文件: Auth.php 项目: johannsl/progsec
 public function checkCredentials($username, $password)
 {
     $user = $this->userRepository->findByUser($username);
     if ($user === false) {
         return false;
     }
     return $this->hash->check($password, $user->getHash(), $user->getSalt());
 }
示例#2
0
 public function checkCredentials($username, $password)
 {
     $user = $this->userRepository->findByUser($username);
     if ($user === false) {
         return false;
     }
     return $this->hash->CheckAPIpassword($password, $username);
 }
示例#3
0
 static function checkCredentials($username, $password)
 {
     $user = User::findByUser($username);
     if ($user === null) {
         return false;
     }
     return Hash::check($password, $user->getPasswordHash());
 }
示例#4
0
 static function insertDummyUsers()
 {
     $hash1 = Hash::make(bin2hex(openssl_random_pseudo_bytes(2)));
     $hash2 = Hash::make('bobdylan');
     $hash3 = Hash::make('liverpool');
     $q1 = "INSERT INTO users(user, pass, isadmin) VALUES ('admin', '{$hash1}', 1)";
     $q2 = "INSERT INTO users(user, pass) VALUES ('bob', '{$hash2}')";
     $q3 = "INSERT INTO users(user, pass) VALUES ('mike', '{$hash3}')";
     self::$pdo->exec($q1);
     self::$pdo->exec($q2);
     self::$pdo->exec($q3);
     print "[tdt4237] Done inserting dummy users." . PHP_EOL;
 }
示例#5
0
 static function insertDummyUsers()
 {
     $hash1 = Hash::make(bin2hex(openssl_random_pseudo_bytes(2)));
     $hash2 = Hash::make('techit');
     $hash3 = Hash::make('mundbjar');
     $q1 = "INSERT INTO users(user, pass, isadmin, first_name, last_name, phone, company, email) VALUES ('systemmanager', '{$hash1}', 1, 'Approv', 'Patents', '53290672', 'Patentsy AS', '*****@*****.**')";
     $q2 = "INSERT INTO users(user, pass, isadmin, first_name, last_name, phone, company, email) VALUES ('ittechnican', '{$hash2}', 1, 'Robert', 'Green', '92300847', 'Patentsy AS', '*****@*****.**')";
     $q3 = "INSERT INTO users(user, pass, isadmin, first_name, last_name, phone, company, email) VALUES ('ceobjarnitorgmund', '{$hash3}', 1, 'Bjarni', 'Torgmund', '32187625', 'Patentsy AS', '*****@*****.**')";
     self::$pdo->exec($q1);
     self::$pdo->exec($q2);
     self::$pdo->exec($q3);
     print "[tdt4237] Done inserting dummy users." . PHP_EOL;
 }
示例#6
0
 static function insertDummyUsers()
 {
     $hash1 = Hash::make(bin2hex(openssl_random_pseudo_bytes(2)));
     $hash2 = Hash::make('bobdylan');
     $hash3 = Hash::make('liverpool');
     $hash4 = Hash::make('Testuser123');
     $q1 = "INSERT INTO users(user, pass, role, fullname, address, postcode) VALUES ('admin', '{$hash1}', 1, 'admin', 'homebase', '9090')";
     $q2 = "INSERT INTO users(user, pass, role, fullname, address, postcode) VALUES ('bob', '{$hash2}', 1, 'Robert Green', 'Greenland Grove 9', '2010')";
     $q3 = "INSERT INTO users(user, pass, role, fullname, address, postcode) VALUES ('bjarni', '{$hash3}', 1, 'Bjarni Torgmund', 'Hummerdale 12', '4120')";
     $qt = "INSERT INTO users(user, pass, role, fullname, address, postcode) VALUES ('testuser', '{$hash4}', 1, 'Teste-Bob', 'Hummerdale 21', '4120')";
     self::$pdo->exec($q1);
     self::$pdo->exec($q2);
     self::$pdo->exec($q3);
     self::$pdo->exec($qt);
     print "[tdt4237] Done inserting dummy users." . PHP_EOL;
 }
示例#7
0
 static function insertDummyUsers()
 {
     $hash1 = Hash::createAPIHash(bin2hex(openssl_random_pseudo_bytes(2)));
     $hash2 = Hash::createAPIHash('bobdylan');
     $hash3 = Hash::createAPIHash('liverpool');
     $hash4 = Hash::createAPIHash('tardis');
     $hash5 = Hash::createAPIHash('Testuser123');
     $q1 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode) VALUES ('admin', '{$hash1}', 1, 'admin', 'homebase', '9090')";
     $q2 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode) VALUES ('bob', '{$hash2}', 1, 'Robert Green', 'Greenland Grove 9', '2010')";
     $q3 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode) VALUES ('bjarni', '{$hash3}', 1, 'Bjarni Torgmund', 'Hummerdale 12', '4120')";
     $q4 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode) VALUES ('drwho', '{$hash4}', 0, 'The Doctor', 'Gallifrey', '4242');";
     $q5 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode) VALUES ('testuser', '{$hash5}', 1, 'Testuser123', 'NTNU', '0001');";
     self::$pdo->exec($q1);
     self::$pdo->exec($q2);
     self::$pdo->exec($q3);
     self::$pdo->exec($q4);
     self::$pdo->exec($q5);
     print "[tdt4237] Done inserting dummy users." . PHP_EOL;
 }
示例#8
0
文件: Sql.php 项目: johannsl/progsec
 static function insertDummyUsers()
 {
     $salt1 = Hash::random_salt();
     $salt2 = Hash::random_salt();
     $salt3 = Hash::random_salt();
     $salt4 = Hash::random_salt();
     $hash1 = Hash::make(bin2hex(openssl_random_pseudo_bytes(10)), $salt1);
     $hash2 = Hash::make(bin2hex(openssl_random_pseudo_bytes(10)), $salt2);
     $hash3 = Hash::make(bin2hex(openssl_random_pseudo_bytes(10)), $salt3);
     $hash4 = Hash::make('Testuser123', $salt4);
     $q1 = "INSERT INTO users(user, pass, salt, is_admin, full_name, address, postcode, bank_acc_num, money_received, money_spent , is_doctor) VALUES ('admin', '{$hash1}', {$salt1},  1, 'admin', 'homebase', '9090', NULL, 0, 0, 0)";
     $q2 = "INSERT INTO users(user, pass, salt, is_admin, full_name, address, postcode, bank_acc_num, money_received, money_spent , is_doctor) VALUES ('bob', '{$hash2}', {$salt2},  1, 'Robert Green', 'Greenland Grove 9', '2010', NULL, 0, 0, 0)";
     $q3 = "INSERT INTO users(user, pass, salt, is_admin, full_name, address, postcode, bank_acc_num, money_received, money_spent , is_doctor) VALUES ('bjarni', '{$hash3}', {$salt3},  1, 'Bjarni Torgmund', 'Hummerdale 12', '4120', NULL, 0, 0, 0)";
     $q4 = "INSERT INTO users(user, pass, salt, is_admin, full_name, address, postcode, bank_acc_num, money_received, money_spent , is_doctor) VALUES ('testuser', '{$hash4}', {$salt4},  1, 'Teaching Assistant', 'NTNU', '7000', NULL, 0, 0, 0)";
     self::$pdo->exec($q1);
     self::$pdo->exec($q2);
     self::$pdo->exec($q3);
     self::$pdo->exec($q4);
     print "[tdt4237] Done inserting dummy users." . PHP_EOL;
 }
示例#9
0
 function create()
 {
     $request = $this->app->request;
     $username = $request->post('user');
     $pass = $request->post('pass');
     $hashed = Hash::make($pass);
     $user = User::makeEmpty();
     $user->setUsername($username);
     $user->setHash($hashed);
     $validationErrors = User::validate($user);
     if (sizeof($validationErrors) > 0) {
         $errors = join("<br>\n", $validationErrors);
         $this->app->flashNow('error', $errors);
         $this->render('newUserForm.twig', ['username' => $username]);
     } else {
         $user->save();
         $this->app->flash('info', 'Thanks for creating a user. Now log in.');
         $this->app->redirect('/login');
     }
 }
示例#10
0
文件: Sql.php 项目: andybb/tdt4237
 static function insertDummyUsers()
 {
     $hash1 = Hash::make('test bil helikopter hest');
     $hash2 = Hash::make('12345dylan');
     $hash3 = Hash::make('0liverpool1');
     $hash4 = Hash::make('Testuser123');
     $hash5 = Hash::make('TestDoctor');
     $q1 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode) VALUES ('admin', '{$hash1}', 1, 'admin', 'homebase', '9090')";
     $q2 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode, bankcard) VALUES ('bob', '{$hash2}', 0, 'Robert Green', 'Greenland Grove 9', '2010', 1234567890123456)";
     $q3 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode) VALUES ('bjarni', '{$hash3}', 0, 'Bjarni Torgmund', 'Hummerdale 12', '4120')";
     $q11 = "INSERT INTO users(user, pass, isadmin, fullname, address, postcode, email, age, bio, bankcard) VALUES ('testuser', '{$hash4}', 1, 'Harald Rex', 'Henrik Ibsens gate 1', '0010', '*****@*****.**', 78, 'Helt konge.', 1234567812345678)";
     $q13 = "INSERT INTO users(user, pass, isdoctor, fullname, address, postcode, email, age, bio, bankcard) VALUES ('testdoctor', '{$hash5}', 1, 'Doctor Jones', 'Henrik Ibsens gate 1', '0010', '*****@*****.**', 30, 'Call me Doctor Jones.', 1234567812345678)";
     $q14 = "INSERT INTO users(user, pass, isdoctor, fullname, address, postcode, email, age, bio) VALUES ('testdoctor2', '{$hash5}', 1, 'Doctor Dre', 'Henrik Ibsens gate 1', '0010', '*****@*****.**', 30, 'Call me Doctor Jones.')";
     self::$pdo->exec($q1);
     self::$pdo->exec($q2);
     self::$pdo->exec($q3);
     self::$pdo->exec($q11);
     self::$pdo->exec($q13);
     self::$pdo->exec($q14);
     print "[tdt4237] Done inserting dummy users." . PHP_EOL;
 }