latest dev + i18n
This commit is contained in:
@@ -6,6 +6,7 @@ export interface AuthTokenData {
|
||||
identifier: string; //will be a sub (id) if logged in or an uuid if anonymous
|
||||
accessToken?: string;
|
||||
username?: string;
|
||||
locale?: string;
|
||||
}
|
||||
export interface AdminSocketTokenData {
|
||||
authorizedRoomIds: string[]; //the list of rooms the client is authorized to read from.
|
||||
@@ -17,8 +18,8 @@ class JWTTokenManager {
|
||||
return Jwt.verify(token, ADMIN_SOCKETS_TOKEN) as AdminSocketTokenData;
|
||||
}
|
||||
|
||||
public createAuthToken(identifier: string, accessToken?: string, username?: string) {
|
||||
return Jwt.sign({ identifier, accessToken, username }, SECRET_KEY, { expiresIn: "30d" });
|
||||
public createAuthToken(identifier: string, accessToken?: string, username?: string, locale?: string) {
|
||||
return Jwt.sign({ identifier, accessToken, username, locale }, SECRET_KEY, { expiresIn: "30d" });
|
||||
}
|
||||
|
||||
public verifyJWTToken(token: string, ignoreExpiration: boolean = false): AuthTokenData {
|
||||
|
||||
@@ -26,7 +26,7 @@ class OpenIDClient {
|
||||
public authorizationUrl(state: string, nonce: string, playUri?: string, redirect?: string) {
|
||||
return this.initClient().then((client) => {
|
||||
return client.authorizationUrl({
|
||||
scope: "openid email",
|
||||
scope: "openid profile email",
|
||||
prompt: "login",
|
||||
state: state,
|
||||
nonce: nonce,
|
||||
@@ -36,7 +36,7 @@ class OpenIDClient {
|
||||
});
|
||||
}
|
||||
|
||||
public getUserInfo(code: string, nonce: string): Promise<{ email: string; sub: string; access_token: string; username: string }> {
|
||||
public getUserInfo(code: string, nonce: string): Promise<{ email: string; sub: string; access_token: string; username: string, locale: string }> {
|
||||
return this.initClient().then((client) => {
|
||||
return client.callback(OPID_CLIENT_REDIRECT_URL, { code }, { nonce }).then((tokenSet) => {
|
||||
return client.userinfo(tokenSet).then((res) => {
|
||||
@@ -46,6 +46,7 @@ class OpenIDClient {
|
||||
sub: res.sub,
|
||||
access_token: tokenSet.access_token as string,
|
||||
username: (res.preferred_username || res.username || res.nickname || res.name || res.email) as string,
|
||||
locale: res.locale as string,
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user