Auth: Improve display of username #98

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-02-02 17:11:35 +01:00
parent 3e8b252a3e
commit a3ee21897d
3 changed files with 10 additions and 15 deletions

View file

@ -117,17 +117,11 @@ export class User extends RestModel {
return this.Details.NickName;
} else if (this.Details && this.Details.GivenName) {
return this.Details.GivenName;
} else if (this.Role) {
return T(Util.capitalize(this.Role));
} else if (this.Details && this.Details.JobTitle) {
return this.Details.JobTitle;
} else if (this.Email) {
return this.Email;
} else if (this.Name) {
return `@${this.Name}`;
return T(Util.capitalize(this.Name));
}
return $gettext("Unregistered");
return $gettext("Unknown");
}
getAccountInfo() {

View file

@ -131,7 +131,7 @@ describe("common/session", () => {
};
session.setData(values2);
const result2 = session.getDisplayName();
assert.equal(result2, "Admin");
assert.equal(result2, "Bar");
session.deleteData();
});

View file

@ -257,13 +257,14 @@ func (m *Session) SetUser(u *User) *Session {
return m
}
// Login returns the login name and provider.
// Login returns the login name.
func (m *Session) Login() string {
if m.AuthProvider == "" {
return m.UserName
} else {
return fmt.Sprintf("%s@%s", m.UserName, m.AuthProvider)
}
return m.UserName
}
// Provider returns the authentication provider name.
func (m *Session) Provider() string {
return m.AuthProvider
}
// SetProvider updates the session's authentication provider.