diff --git a/src/css/states/main_menu.scss b/src/css/states/main_menu.scss index 0d16163b..6043365b 100644 --- a/src/css/states/main_menu.scss +++ b/src/css/states/main_menu.scss @@ -49,45 +49,6 @@ } } - .steamSso { - position: fixed; - @include S(top, 0px); - @include S(left, 10px); - background: rgba(88, 92, 102, 0.4); - @include SuperSmallText; - color: #fff; - @include S(max-width, 150px); - @include S(border-radius, $globalBorderRadius); - border-top-left-radius: 0; - border-top-right-radius: 0; - @include S(padding, 5px); - box-shadow: 0 D(5px) D(15px) rgba(#000, 0.1); - display: flex; - color: #000; - flex-direction: column; - - a.ssoSignIn { - background: #171a23 uiResource("steam_signin.png") center center / contain no-repeat; - @include S(width, 110px); - @include S(height, 19px); - display: inline-flex; - @include S(border-radius, $globalBorderRadius); - @include S(margin-top, 3px); - overflow: hidden; - text-indent: -999em; - &:hover { - opacity: 0.95; - } - } - - @include DarkThemeOverride { - color: #333539; - a { - color: #111; - } - } - } - .fullscreenBackgroundVideo { // display: none !important; z-index: -1; @@ -972,6 +933,51 @@ } } + > .steamSso { + background: rgba($colorBlueBright, 0.9); + &:hover { + background: rgba($colorBlueBright, 0.9); + } + // @include SuperSmallText; + // color: #fff; + // @include S(max-width, 150px); + // @include S(border-radius, $globalBorderRadius); + // border-top-left-radius: 0; + // border-top-right-radius: 0; + @include S(padding, 5px); + // box-shadow: 0 D(5px) D(15px) rgba(#000, 0.1); + // color: #000; + display: flex; + color: #222428; + flex-direction: column; + + @include S(font-size, 9px); + + a.ssoSignIn { + background: #171a23 uiResource("steam_signin.png") center center / contain no-repeat; + width: 100%; + box-sizing: border-box; + @include S(height, 16px); + @include S(min-height, 16px); + + display: inline-flex; + @include S(border-radius, $globalBorderRadius * 0.5); + @include S(margin-top, 3px); + overflow: hidden; + text-indent: -999em; + &:hover { + opacity: 0.95; + } + } + + @include DarkThemeOverride { + color: #333539; + a { + color: #111; + } + } + } + > .sidelinks { display: grid; align-items: flex-start; diff --git a/src/js/core/steam_sso.js b/src/js/core/steam_sso.js index f04fb3bc..67c6d582 100644 --- a/src/js/core/steam_sso.js +++ b/src/js/core/steam_sso.js @@ -51,29 +51,37 @@ export async function authorizeViaSSOToken(app, dialogs) { return; } - const response = await Promise.race([ - fetch(apiUrl + "/v1/sso/refresh", { - method: "POST", - body: token, - headers: { - "x-api-key": "d5c54aaa491f200709afff082c153ef2", - }, - }), - new Promise((resolve, reject) => { - setTimeout(() => reject("timeout exceeded"), 20000); - }), - ]); - const responseText = await response.json(); - if (!responseText.token) { - console.warn("Failed to register"); - window.localStorage.setItem("steam_sso_auth_token", ""); - window.location.replace("?sso_logout"); - return; - } + try { + const response = await Promise.race([ + fetch(apiUrl + "/v1/sso/refresh", { + method: "POST", + body: token, + headers: { + "x-api-key": "d5c54aaa491f200709afff082c153ef2", + }, + }), + new Promise((resolve, reject) => { + setTimeout(() => reject("timeout exceeded"), 20000); + }), + ]); - window.localStorage.setItem("steam_sso_auth_token", responseText.token); - app.clientApi.token = responseText.token; - WEB_STEAM_SSO_AUTHENTICATED = true; + const responseText = await response.json(); + if (!responseText.token) { + console.warn("Failed to register"); + window.localStorage.setItem("steam_sso_auth_token", ""); + window.location.replace("?sso_logout"); + return; + } + + window.localStorage.setItem("steam_sso_auth_token", responseText.token); + app.clientApi.token = responseText.token; + WEB_STEAM_SSO_AUTHENTICATED = true; + } catch (ex) { + console.warn("Auth failure", ex); + window.localStorage.setItem("steam_sso_auth_token", ""); + window.location.replace("/"); + return new Promise(() => null); + } }; await verify(); diff --git a/src/js/states/main_menu.js b/src/js/states/main_menu.js index cd1bccc8..f1a0de9a 100644 --- a/src/js/states/main_menu.js +++ b/src/js/states/main_menu.js @@ -120,25 +120,6 @@ export class MainMenuState extends GameState { ${showExitAppButton ? `` : ""} - ${ - G_IS_STANDALONE || WEB_STEAM_SSO_AUTHENTICATED - ? "" - : `
- ${T.mainMenu.playFullVersion} - Sign in -
` - } - ${ - WEB_STEAM_SSO_AUTHENTICATED - ? ` -
${T.mainMenu.playingFullVersion} - ${T.mainMenu.logout} -
- ` - : "" - }