1
1
<?php
2
- namespace Auth \Core ;
2
+ namespace Riculum \ Auth \core ;
3
3
4
- use Auth \Exceptions \UserAlreadyExistsException ;
5
- use Database \Core \Database as DB ;
6
4
use Exception ;
5
+ use Riculum \Auth \exceptions \UserAlreadyExistsException ;
6
+ use Riculum \Database as DB ;
7
7
8
8
class User
9
9
{
@@ -18,7 +18,7 @@ private static function emailIsUnique(string $email): bool
18
18
}
19
19
20
20
/**
21
- * Output the 36 character UUID
21
+ * Output the 36 character UUIDv4
22
22
* @throws Exception
23
23
*/
24
24
private static function generateUuid (): string
@@ -76,21 +76,13 @@ static function addUser(array $user): ?int
76
76
{
77
77
if (self ::emailIsUnique ($ user ['email ' ])) {
78
78
$ user ['uuid ' ] = self ::generateUuid ();
79
+ $ user ['resetToken ' ] = bin2hex (random_bytes (16 ));
79
80
return DB ::insertAssoc ($ _ENV ['DB_PREFIX ' ].'user ' , $ user );
80
81
} else {
81
82
throw new UserAlreadyExistsException ('User with email ' . $ user ['email ' ] . ' already exists ' );
82
83
}
83
84
}
84
85
85
- /**
86
- * @param string $uuid
87
- * @return void
88
- */
89
- static function deleteUser (string $ uuid )
90
- {
91
- DB ::delete ("DELETE FROM " . $ _ENV ['DB_PREFIX ' ] . "user WHERE uuid = ? " , [$ uuid ]);
92
- }
93
-
94
86
/**
95
87
* @param string $uuid
96
88
* @return array|null
@@ -100,14 +92,6 @@ static function getUser(string $uuid): ?array
100
92
return DB ::single ('SELECT * FROM ' . $ _ENV ['DB_PREFIX ' ] . 'user WHERE uuid = ? ' , [$ uuid ]);
101
93
}
102
94
103
- /**
104
- * @return array|null
105
- */
106
- static function getUsers (): ?array
107
- {
108
- return DB ::select ('SELECT * FROM ' . $ _ENV ['DB_PREFIX ' ] . 'user ' , []);
109
- }
110
-
111
95
/**
112
96
* @param string $email
113
97
* @return array|null
0 commit comments