| Conditions | 5 |
| Paths | 5 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public static function createUserFromPostValues($postValues) |
||
| 25 | { |
||
| 26 | if (isset($postValues['username'])) { |
||
| 27 | $user = new \stdClass(); |
||
| 28 | $user->username = $postValues['username']; |
||
| 29 | $user->slug = StringUtil::slugify($postValues['username']); |
||
| 30 | $user->rights = array(); |
||
| 31 | if (isset($postValues['rights'])) { |
||
| 32 | $user->rights = $postValues['rights']; |
||
| 33 | } |
||
| 34 | |||
| 35 | if (isset($postValues['password']) && empty($postValues['password']) === false) { |
||
| 36 | $crypt = new Crypt(); |
||
| 37 | $user->password = $crypt->encrypt($postValues['password'], 16); |
||
| 38 | $user->salt = $crypt->getLastSalt(); |
||
| 39 | } else { |
||
| 40 | $user->password = $postValues['passHash']; |
||
| 41 | $user->salt = $postValues['salt']; |
||
| 42 | } |
||
| 43 | |||
| 44 | return $user; |
||
| 45 | } else { |
||
| 46 | throw new \Exception('Trying to create user with invalid data.'); |
||
| 47 | } |
||
| 49 | } |