Skip to content

Commit fb01e9d

Browse files
author
m-tanabe
committed
Add getUsername function
1 parent dcabee7 commit fb01e9d

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

caliper/app/Caliper/Traits/Util.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ protected function getUser(string $id): ?User
3131
}
3232
}
3333

34-
public function getAnonymizedUsername(User $actor): string
34+
public function getUsername(User $actor): ?string
3535
{
3636
if ($this->isEnabledEppn()) {
37-
$username = ($actor->auth === 'lti')
37+
return ($actor->auth === 'lti')
3838
? $actor->alternatename
3939
: $actor->username;
40+
} else {
41+
return $actor->username;
42+
}
43+
}
44+
45+
public function getAnonymizedUsername(User $actor): string
46+
{
47+
if ($this->isEnabledEppn()) {
48+
$username = $this->getUsername($actor);
4049
$hash = $username ? hash('sha256', $username) : '';
4150
$eppn = Eppn::where('username', $username)->first();
4251
if (is_null($eppn)) {

0 commit comments

Comments
 (0)