diff --git a/app/app.ejs b/app/app.ejs index e829fa14..2958a401 100644 --- a/app/app.ejs +++ b/app/app.ejs @@ -1,7 +1,7 @@ - Helios Launcher + Site-33 Launcher @@ -41,7 +41,7 @@
- +
diff --git a/app/assets/js/authmanager.js b/app/assets/js/authmanager.js index 3f431440..ed627604 100644 --- a/app/assets/js/authmanager.js +++ b/app/assets/js/authmanager.js @@ -9,14 +9,16 @@ * @module authmanager */ // Requirements -const ConfigManager = require('./configmanager') -const { LoggerUtil } = require('helios-core') -const { RestResponseStatus } = require('helios-core/common') -const { MojangRestAPI, mojangErrorDisplayable, MojangErrorCode } = require('helios-core/mojang') -const { MicrosoftAuth, microsoftErrorDisplayable, MicrosoftErrorCode } = require('helios-core/microsoft') -const { AZURE_CLIENT_ID } = require('./ipcconstants') +const ConfigManager = require('./configmanager') +const { LoggerUtil } = require('helios-core') +const { RestResponseStatus } = require('helios-core/common') +//const { MojangRestAPI, mojangErrorDisplayable, MojangErrorCode } = require('helios-core/mojang') +//const { MicrosoftAuth, microsoftErrorDisplayable, MicrosoftErrorCode } = require('helios-core/microsoft') +//const { AZURE_CLIENT_ID } = require('./ipcconstants') -const log = LoggerUtil.getLogger('AuthManager') +const azAuth = require('azuriom-auth') + +const log = LoggerUtil.getLogger('AuthManager') // Functions @@ -25,19 +27,37 @@ const log = LoggerUtil.getLogger('AuthManager') * authserver. The resultant data will be stored as an auth account in the * configuration database. * - * @param {string} username The account username (email if migrated). + * @param {string} email The account username (email if migrated). * @param {string} password The account password. + * @param {number} a2f The account a2f * @returns {Promise.} Promise which resolves the resolved authenticated account object. */ -exports.addMojangAccount = async function(username, password) { - try { - const response = await MojangRestAPI.authenticate(username, password, ConfigManager.getClientToken()) +exports.addMojangAccount = async function(email, password, a2f) { + const auth = new azAuth.AuthClient('https://site-33.net') + + let result + + if (a2f === null) result = await auth.login(email, password) + else result = await auth.login(email, password, a2f) + + if (result.status === 'pending' && result.requires2fa) result = await auth.login(email, password, a2f) + + if (result.status !== 'success') { + throw 'Unexpected result: ' + JSON.stringify(result) + } + + const ret = ConfigManager.addAzAuthAccount(result.uuid, result.accessToken, result.username, result.username, result.role.id, result.role.name, result.role.color) + ConfigManager.save() + + return ret + /**try { + const response = await MojangRestAPI.authenticate(username, password, ConfigManager.getClientToken()) console.log(response) if(response.responseStatus === RestResponseStatus.SUCCESS) { - const session = response.data + const session = response.data if(session.selectedProfile != null){ - const ret = ConfigManager.addMojangAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name) + const ret = ConfigManager.addMojangAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name) if(ConfigManager.getClientToken() == null){ ConfigManager.setClientToken(session.clientToken) } @@ -54,10 +74,10 @@ exports.addMojangAccount = async function(username, password) { } catch (err){ log.error(err) return Promise.reject(mojangErrorDisplayable(MojangErrorCode.UNKNOWN)) - } + }*/ } -const AUTH_MODE = { FULL: 0, MS_REFRESH: 1, MC_REFRESH: 2 } +const AUTH_MODE = { FULL: 0, MS_REFRESH: 1, MC_REFRESH: 2 } /** * Perform the full MS Auth flow in a given mode. @@ -70,51 +90,51 @@ const AUTH_MODE = { FULL: 0, MS_REFRESH: 1, MC_REFRESH: 2 } * @param {*} authMode The auth mode. * @returns An object with all auth data. AccessToken object will be null when mode is MC_REFRESH. */ -async function fullMicrosoftAuthFlow(entryCode, authMode) { +/**async function fullMicrosoftAuthFlow(entryCode, authMode) { try { let accessTokenRaw let accessToken if(authMode !== AUTH_MODE.MC_REFRESH) { - const accessTokenResponse = await MicrosoftAuth.getAccessToken(entryCode, authMode === AUTH_MODE.MS_REFRESH, AZURE_CLIENT_ID) + const accessTokenResponse = await MicrosoftAuth.getAccessToken(entryCode, authMode === AUTH_MODE.MS_REFRESH, AZURE_CLIENT_ID) if(accessTokenResponse.responseStatus === RestResponseStatus.ERROR) { return Promise.reject(microsoftErrorDisplayable(accessTokenResponse.microsoftErrorCode)) } - accessToken = accessTokenResponse.data - accessTokenRaw = accessToken.access_token + accessToken = accessTokenResponse.data + accessTokenRaw = accessToken.access_token } else { - accessTokenRaw = entryCode + accessTokenRaw = entryCode } - const xblResponse = await MicrosoftAuth.getXBLToken(accessTokenRaw) + const xblResponse = await MicrosoftAuth.getXBLToken(accessTokenRaw) if(xblResponse.responseStatus === RestResponseStatus.ERROR) { return Promise.reject(microsoftErrorDisplayable(xblResponse.microsoftErrorCode)) } - const xstsResonse = await MicrosoftAuth.getXSTSToken(xblResponse.data) + const xstsResonse = await MicrosoftAuth.getXSTSToken(xblResponse.data) if(xstsResonse.responseStatus === RestResponseStatus.ERROR) { return Promise.reject(microsoftErrorDisplayable(xstsResonse.microsoftErrorCode)) } - const mcTokenResponse = await MicrosoftAuth.getMCAccessToken(xstsResonse.data) + const mcTokenResponse = await MicrosoftAuth.getMCAccessToken(xstsResonse.data) if(mcTokenResponse.responseStatus === RestResponseStatus.ERROR) { return Promise.reject(microsoftErrorDisplayable(mcTokenResponse.microsoftErrorCode)) } - const mcProfileResponse = await MicrosoftAuth.getMCProfile(mcTokenResponse.data.access_token) + const mcProfileResponse = await MicrosoftAuth.getMCProfile(mcTokenResponse.data.access_token) if(mcProfileResponse.responseStatus === RestResponseStatus.ERROR) { return Promise.reject(microsoftErrorDisplayable(mcProfileResponse.microsoftErrorCode)) } return { accessToken, accessTokenRaw, - xbl: xblResponse.data, - xsts: xstsResonse.data, - mcToken: mcTokenResponse.data, - mcProfile: mcProfileResponse.data + xbl : xblResponse.data, + xsts : xstsResonse.data, + mcToken : mcTokenResponse.data, + mcProfile : mcProfileResponse.data } } catch(err) { log.error(err) return Promise.reject(microsoftErrorDisplayable(MicrosoftErrorCode.UNKNOWN)) } -} +}*/ /** * Calculate the expiry date. Advance the expiry time by 10 seconds @@ -135,14 +155,14 @@ function calculateExpiryDate(nowMs, epiresInS) { * @param {string} authCode The authCode obtained from microsoft. * @returns {Promise.} Promise which resolves the resolved authenticated account object. */ -exports.addMicrosoftAccount = async function(authCode) { +/**exports.addMicrosoftAccount = async function(authCode) { - const fullAuth = await fullMicrosoftAuthFlow(authCode, AUTH_MODE.FULL) + const fullAuth = await fullMicrosoftAuthFlow(authCode, AUTH_MODE.FULL) // Advance expiry by 10 seconds to avoid close calls. - const now = new Date().getTime() + const now = new Date().getTime() - const ret = ConfigManager.addMicrosoftAuthAccount( + const ret = ConfigManager.addMicrosoftAuthAccount( fullAuth.mcProfile.id, fullAuth.mcToken.access_token, fullAuth.mcProfile.name, @@ -154,7 +174,7 @@ exports.addMicrosoftAccount = async function(authCode) { ConfigManager.save() return ret -} +}*/ /** * Remove a Mojang account. This will invalidate the access token associated @@ -165,8 +185,8 @@ exports.addMicrosoftAccount = async function(authCode) { */ exports.removeMojangAccount = async function(uuid){ try { - const authAcc = ConfigManager.getAuthAccount(uuid) - const response = await MojangRestAPI.invalidate(authAcc.accessToken, ConfigManager.getClientToken()) + const authAcc = ConfigManager.getAuthAccount(uuid) + const response = await MojangRestAPI.invalidate(authAcc.accessToken, ConfigManager.getClientToken()) if(response.responseStatus === RestResponseStatus.SUCCESS) { ConfigManager.removeAuthAccount(uuid) ConfigManager.save() @@ -182,14 +202,19 @@ exports.removeMojangAccount = async function(uuid){ } /** - * Remove a Microsoft account. It is expected that the caller will invoke the OAuth logout - * through the ipc renderer. + * Remove a AzAuth account. This will invalidate the access token associated + * with the account and then remove it from the database. * * @param {string} uuid The UUID of the account to be removed. + * @param {string} accessToken The UUID of the account to be removed. * @returns {Promise.} Promise which resolves to void when the action is complete. */ -exports.removeMicrosoftAccount = async function(uuid){ +exports.removeAzAuthAccount = async function(uuid, accessToken) { try { + //const authAcc = ConfigManager.getAuthAccount(uuid) + //let rep = AuthClient.logout(authAcc.accessToken) + //console.log(rep) + //azAuth.AuthClient.logout(accessToken) ConfigManager.removeAuthAccount(uuid) ConfigManager.save() return Promise.resolve() @@ -199,6 +224,24 @@ exports.removeMicrosoftAccount = async function(uuid){ } } +/** + * Remove a Microsoft account. It is expected that the caller will invoke the OAuth logout + * through the ipc renderer. + * + * @param {string} uuid The UUID of the account to be removed. + * @returns {Promise.} Promise which resolves to void when the action is complete. + */ +/**exports.removeMicrosoftAccount = async function(uuid){ + try { + ConfigManager.removeAuthAccount(uuid) + ConfigManager.save() + return Promise.resolve() + } catch (err){ + log.error('Error while removing account', err) + return Promise.reject(err) + } +}*/ + /** * Validate the selected account with Mojang's authserver. If the account is not valid, * we will attempt to refresh the access token and update that value. If that fails, a @@ -208,15 +251,15 @@ exports.removeMicrosoftAccount = async function(uuid){ * otherwise false. */ async function validateSelectedMojangAccount(){ - const current = ConfigManager.getSelectedAccount() - const response = await MojangRestAPI.validate(current.accessToken, ConfigManager.getClientToken()) + const current = ConfigManager.getSelectedAccount() + /**const response = await MojangRestAPI.validate(current.accessToken, ConfigManager.getClientToken()) if(response.responseStatus === RestResponseStatus.SUCCESS) { - const isValid = response.data + const isValid = response.data if(!isValid){ - const refreshResponse = await MojangRestAPI.refresh(current.accessToken, ConfigManager.getClientToken()) + const refreshResponse = await MojangRestAPI.refresh(current.accessToken, ConfigManager.getClientToken()) if(refreshResponse.responseStatus === RestResponseStatus.SUCCESS) { - const session = refreshResponse.data + const session = refreshResponse.data ConfigManager.updateMojangAuthAccount(current.uuid, session.accessToken) ConfigManager.save() } else { @@ -230,8 +273,7 @@ async function validateSelectedMojangAccount(){ log.info('Account access token validated.') return true } - } - + }*/ } /** @@ -242,11 +284,11 @@ async function validateSelectedMojangAccount(){ * @returns {Promise.} Promise which resolves to true if the access token is valid, * otherwise false. */ -async function validateSelectedMicrosoftAccount(){ - const current = ConfigManager.getSelectedAccount() - const now = new Date().getTime() - const mcExpiresAt = current.expiresAt - const mcExpired = now >= mcExpiresAt +/**async function validateSelectedMicrosoftAccount(){ + const current = ConfigManager.getSelectedAccount() + const now = new Date().getTime() + const mcExpiresAt = current.expiresAt + const mcExpired = now >= mcExpiresAt if(!mcExpired) { return true @@ -254,13 +296,13 @@ async function validateSelectedMicrosoftAccount(){ // MC token expired. Check MS token. - const msExpiresAt = current.microsoft.expires_at - const msExpired = now >= msExpiresAt + const msExpiresAt = current.microsoft.expires_at + const msExpired = now >= msExpiresAt if(msExpired) { // MS expired, do full refresh. try { - const res = await fullMicrosoftAuthFlow(current.microsoft.refresh_token, AUTH_MODE.MS_REFRESH) + const res = await fullMicrosoftAuthFlow(current.microsoft.refresh_token, AUTH_MODE.MS_REFRESH) ConfigManager.updateMicrosoftAuthAccount( current.uuid, @@ -278,7 +320,7 @@ async function validateSelectedMicrosoftAccount(){ } else { // Only MC expired, use existing MS token. try { - const res = await fullMicrosoftAuthFlow(current.microsoft.access_token, AUTH_MODE.MC_REFRESH) + const res = await fullMicrosoftAuthFlow(current.microsoft.access_token, AUTH_MODE.MC_REFRESH) ConfigManager.updateMicrosoftAuthAccount( current.uuid, @@ -295,7 +337,7 @@ async function validateSelectedMicrosoftAccount(){ return false } } -} +}*/ /** * Validate the selected auth account. @@ -304,12 +346,12 @@ async function validateSelectedMicrosoftAccount(){ * otherwise false. */ exports.validateSelected = async function(){ - const current = ConfigManager.getSelectedAccount() + const current = ConfigManager.getSelectedAccount() - if(current.type === 'microsoft') { + /**if(current.type === 'microsoft') { return await validateSelectedMicrosoftAccount() } else { return await validateSelectedMojangAccount() - } - -} + }*/ + return await validateSelectedMojangAccount() +} \ No newline at end of file diff --git a/app/assets/js/configmanager.js b/app/assets/js/configmanager.js index c3f74897..071c90a9 100644 --- a/app/assets/js/configmanager.js +++ b/app/assets/js/configmanager.js @@ -337,10 +337,15 @@ exports.getAuthAccount = function(uuid){ * * @returns {Object} The authenticated account object created by this action. */ -exports.updateMojangAuthAccount = function(uuid, accessToken){ +/**exports.updateMojangAuthAccount = function(uuid, accessToken){ config.authenticationDatabase[uuid].accessToken = accessToken config.authenticationDatabase[uuid].type = 'mojang' // For gradual conversion. return config.authenticationDatabase[uuid] +}*/ +exports.updateAzAuthAccount = function(uuid, accessToken){ + config.authenticationDatabase[uuid].accessToken = accessToken + config.authenticationDatabase[uuid].type = 'azAuth' // For gradual conversion. + return config.authenticationDatabase[uuid] } /** @@ -353,7 +358,7 @@ exports.updateMojangAuthAccount = function(uuid, accessToken){ * * @returns {Object} The authenticated account object created by this action. */ -exports.addMojangAuthAccount = function(uuid, accessToken, username, displayName){ +/**exports.addMojangAuthAccount = function(uuid, accessToken, username, displayName){ config.selectedAccount = uuid config.authenticationDatabase[uuid] = { type: 'mojang', @@ -363,6 +368,34 @@ exports.addMojangAuthAccount = function(uuid, accessToken, username, displayName displayName: displayName.trim() } return config.authenticationDatabase[uuid] +}*/ + +/** + * Adds an authenticated azuriom account to the database to be stored. + * + * @param {string} uuid The uuid of the authenticated account. + * @param {string} accessToken The accessToken of the authenticated account. + * @param {string} username The username (usually email) of the authenticated account. + * @param {string} displayName The in game name of the authenticated account. + * @param {string} roleid The roleId + * @param {string} rolename The roleName + * @param {string} rolecolor The roleColor + * + * @returns {Object} The authenticated account object created by this action. + */ +exports.addAzAuthAccount = function(uuid, accessToken, username, displayName, roleid, rolename, rolecolor) { + config.selectedAccount = uuid + config.authenticationDatabase[uuid] = { + type: 'azAuth', + accessToken, + username: username.trim(), + uuid: uuid.toString(), + displayName: displayName.trim(), + roleid: roleid, + rolename: rolename, + rolecolor: rolecolor + } + return config.authenticationDatabase[uuid] } /** @@ -377,14 +410,14 @@ exports.addMojangAuthAccount = function(uuid, accessToken, username, displayName * * @returns {Object} The authenticated account object created by this action. */ -exports.updateMicrosoftAuthAccount = function(uuid, accessToken, msAccessToken, msRefreshToken, msExpires, mcExpires) { +/**exports.updateMicrosoftAuthAccount = function(uuid, accessToken, msAccessToken, msRefreshToken, msExpires, mcExpires) { config.authenticationDatabase[uuid].accessToken = accessToken config.authenticationDatabase[uuid].expiresAt = mcExpires config.authenticationDatabase[uuid].microsoft.access_token = msAccessToken config.authenticationDatabase[uuid].microsoft.refresh_token = msRefreshToken config.authenticationDatabase[uuid].microsoft.expires_at = msExpires return config.authenticationDatabase[uuid] -} +}*/ /** * Adds an authenticated microsoft account to the database to be stored. @@ -399,7 +432,7 @@ exports.updateMicrosoftAuthAccount = function(uuid, accessToken, msAccessToken, * * @returns {Object} The authenticated account object created by this action. */ -exports.addMicrosoftAuthAccount = function(uuid, accessToken, name, mcExpires, msAccessToken, msRefreshToken, msExpires) { +/*exports.addMicrosoftAuthAccount = function(uuid, accessToken, name, mcExpires, msAccessToken, msRefreshToken, msExpires) { config.selectedAccount = uuid config.authenticationDatabase[uuid] = { type: 'microsoft', @@ -415,7 +448,7 @@ exports.addMicrosoftAuthAccount = function(uuid, accessToken, name, mcExpires, m } } return config.authenticationDatabase[uuid] -} +}*/ /** * Remove an authenticated account from the database. If the account diff --git a/app/assets/js/ipcconstants.js b/app/assets/js/ipcconstants.js index a1cd6385..a04f666d 100644 --- a/app/assets/js/ipcconstants.js +++ b/app/assets/js/ipcconstants.js @@ -1,7 +1,7 @@ // NOTE FOR THIRD-PARTY // REPLACE THIS CLIENT ID WITH YOUR APPLICATION ID. // SEE https://github.com/dscalzi/HeliosLauncher/blob/master/docs/MicrosoftAuth.md -exports.AZURE_CLIENT_ID = '1ce6e35a-126f-48fd-97fb-54d143ac6d45' +/* exports.AZURE_CLIENT_ID = '1ce6e35a-126f-48fd-97fb-54d143ac6d45' // SEE NOTE ABOVE. @@ -22,7 +22,7 @@ exports.MSFT_ERROR = { ALREADY_OPEN: 'MSFT_AUTH_ERR_ALREADY_OPEN', NOT_FINISHED: 'MSFT_AUTH_ERR_NOT_FINISHED' } - + */ exports.SHELL_OPCODE = { TRASH_ITEM: 'TRASH_ITEM' } \ No newline at end of file diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index a7a2d0c6..03489047 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -132,7 +132,7 @@ function updateSelectedAccount(authUser){ username = authUser.displayName } if(authUser.uuid != null){ - document.getElementById('avatarContainer').style.backgroundImage = `url('https://mc-heads.net/body/${authUser.uuid}/right')` + document.getElementById('avatarContainer').style.backgroundImage = `url('https://site-33.net/api/skin-api/avatars/face/${authUser.username}')` } } user_text.innerHTML = username @@ -231,7 +231,6 @@ const refreshServerStatus = async function(fade = false){ const serverURL = new URL('my://' + serv.getAddress()) const servStat = await getServerStatus(47, serverURL.hostname, Number(serverURL.port)) - console.log(servStat) pLabel = 'PLAYERS' pVal = servStat.players.online + '/' + servStat.players.max @@ -1092,7 +1091,7 @@ function displayArticle(articleObject, index){ function loadNews(){ return new Promise((resolve, reject) => { const distroData = DistroManager.getDistribution() - const newsFeed = distroData.getRSS() + const newsFeed = isDev ? "https://site-33.net/api/rss" : distroData.getRSS() const newsHost = new URL(newsFeed).origin + '/' $.ajax({ url: newsFeed, @@ -1105,7 +1104,7 @@ function loadNews(){ const el = $(items[i]) // Resolve date. - const date = new Date(el.find('pubDate').text()).toLocaleDateString('en-US', {month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric'}) + const date = new Date(el.find('pubDate').text()).toLocaleDateString('fr-FR', {month: 'short', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric'}) // Resolve comments. let comments = el.find('slash\\:comments').text() || '0' @@ -1122,11 +1121,13 @@ function loadNews(){ let link = el.find('link').text() let title = el.find('title').text() let author = el.find('dc\\:creator').text() + let img = el.find('enclosure').attr('url') // Generate article. articles.push( { link, + img, title, date, author, diff --git a/app/assets/js/scripts/login.js b/app/assets/js/scripts/login.js index 2b6d0c02..94e14e9c 100644 --- a/app/assets/js/scripts/login.js +++ b/app/assets/js/scripts/login.js @@ -10,9 +10,11 @@ const basicEmail = /^\S+@\S+\.\S+$/ const loginCancelContainer = document.getElementById('loginCancelContainer') const loginCancelButton = document.getElementById('loginCancelButton') const loginEmailError = document.getElementById('loginEmailError') -const loginUsername = document.getElementById('loginUsername') +const loginEmail = document.getElementById('loginEmail') const loginPasswordError = document.getElementById('loginPasswordError') const loginPassword = document.getElementById('loginPassword') +const loginA2FError = document.getElementById('loginA2FError') +const loginA2F = document.getElementById('loginA2F') const checkmarkContainer = document.getElementById('checkmarkContainer') const loginRememberOption = document.getElementById('loginRememberOption') const loginButton = document.getElementById('loginButton') @@ -91,7 +93,7 @@ function validatePassword(value){ } // Emphasize errors with shake when focus is lost. -loginUsername.addEventListener('focusout', (e) => { +loginEmail.addEventListener('focusout', (e) => { validateEmail(e.target.value) shakeError(loginEmailError) }) @@ -101,7 +103,7 @@ loginPassword.addEventListener('focusout', (e) => { }) // Validate input for each field. -loginUsername.addEventListener('input', (e) => { +loginEmail.addEventListener('input', (e) => { validateEmail(e.target.value) }) loginPassword.addEventListener('input', (e) => { @@ -142,7 +144,7 @@ function loginLoading(v){ function formDisabled(v){ loginDisabled(v) loginCancelButton.disabled = v - loginUsername.disabled = v + loginEmail.disabled = v loginPassword.disabled = v if(v){ checkmarkContainer.setAttribute('disabled', v) @@ -166,7 +168,7 @@ function loginCancelEnabled(val){ loginCancelButton.onclick = (e) => { switchView(getCurrentView(), loginViewOnCancel, 500, 500, () => { - loginUsername.value = '' + loginEmail.value = '' loginPassword.value = '' loginCancelEnabled(false) if(loginViewCancelHandler != null){ @@ -181,13 +183,16 @@ loginForm.onsubmit = () => { return false } // Bind login button behavior. loginButton.addEventListener('click', () => { - // Disable form. formDisabled(true) // Show loading stuff. loginLoading(true) - AuthManager.addMojangAccount(loginUsername.value, loginPassword.value).then((value) => { + login(loginEmail.value, loginPassword.value, loginA2F.value == undefined ? null : loginA2F.value) +}) + +function login(email, password, a2f) { + AuthManager.addMojangAccount(email, password, a2f).then((value) => { updateSelectedAccount(value) loginButton.innerHTML = loginButton.innerHTML.replace(Lang.queryJS('login.loggingIn'), Lang.queryJS('login.success')) $('.circle-loader').toggleClass('load-complete') @@ -201,8 +206,9 @@ loginButton.addEventListener('click', () => { loginViewOnSuccess = VIEWS.landing // Reset this for good measure. loginCancelEnabled(false) // Reset this for good measure. loginViewCancelHandler = null // Reset this for good measure. - loginUsername.value = '' + loginEmail.value = '' loginPassword.value = '' + loginA2F.value = '' $('.circle-loader').toggleClass('load-complete') $('.checkmark').toggle() loginLoading(false) @@ -215,14 +221,14 @@ loginButton.addEventListener('click', () => { let actualDisplayableError if(isDisplayableError(displayableError)) { - msftLoginLogger.error('Error while logging in.', displayableError) + console.log('Error while logging in.', displayableError) actualDisplayableError = displayableError } else { // Uh oh. - msftLoginLogger.error('Unhandled error during login.', displayableError) + console.log('Unhandled error during login.', displayableError) actualDisplayableError = { - title: 'Unknown Error During Login', - desc: 'An unknown error has occurred. Please see the console for details.' + title: 'Erreur inconnue pendant la connexion', + desc: 'Une erreur inconnue s\'est produite. Veuillez consulter la console pour plus de détails.' } } @@ -233,5 +239,4 @@ loginButton.addEventListener('click', () => { }) toggleOverlay(true) }) - -}) \ No newline at end of file +} \ No newline at end of file diff --git a/app/assets/js/scripts/loginOptions.js b/app/assets/js/scripts/loginOptions.js index cdb1bc8e..bf4c37fa 100644 --- a/app/assets/js/scripts/loginOptions.js +++ b/app/assets/js/scripts/loginOptions.js @@ -1,5 +1,5 @@ const loginOptionsCancelContainer = document.getElementById('loginOptionCancelContainer') -const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft') +/* const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft') */ const loginOptionMojang = document.getElementById('loginOptionMojang') const loginOptionsCancelButton = document.getElementById('loginOptionCancelButton') @@ -18,7 +18,7 @@ function loginOptionsCancelEnabled(val){ } } -loginOptionMicrosoft.onclick = (e) => { +/* loginOptionMicrosoft.onclick = (e) => { switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => { ipcRenderer.send( MSFT_OPCODE.OPEN_LOGIN, @@ -26,7 +26,7 @@ loginOptionMicrosoft.onclick = (e) => { loginOptionsViewOnLoginCancel ) }) -} +} */ loginOptionMojang.onclick = (e) => { switchView(getCurrentView(), VIEWS.login, 500, 500, () => { diff --git a/app/assets/js/scripts/overlay.js b/app/assets/js/scripts/overlay.js index cf2c5c98..976d3285 100644 --- a/app/assets/js/scripts/overlay.js +++ b/app/assets/js/scripts/overlay.js @@ -305,7 +305,7 @@ function populateAccountListings(){ let htmlString = '' for(let i=0; i - +
${accounts[i].displayName}
` } diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index 2a4ad209..4a19d2a2 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -4,7 +4,7 @@ const semver = require('semver') const { JavaGuard } = require('./assets/js/assetguard') const DropinModUtil = require('./assets/js/dropinmodutil') -const { MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR } = require('./assets/js/ipcconstants') +/* const { MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR } = require('./assets/js/ipcconstants') */ const settingsState = { invalid: new Set() @@ -339,8 +339,8 @@ settingsNavDone.onclick = () => { * Account Management Tab */ -const msftLoginLogger = LoggerUtil.getLogger('Microsoft Login') -const msftLogoutLogger = LoggerUtil.getLogger('Microsoft Logout') +/*const msftLoginLogger = LoggerUtil.getLogger('Microsoft Login') +const msftLogoutLogger = LoggerUtil.getLogger('Microsoft Logout')*/ // Bind the add mojang account button. document.getElementById('settingsAddMojangAccount').onclick = (e) => { @@ -352,7 +352,7 @@ document.getElementById('settingsAddMojangAccount').onclick = (e) => { } // Bind the add microsoft account button. -document.getElementById('settingsAddMicrosoftAccount').onclick = (e) => { +/* document.getElementById('settingsAddMicrosoftAccount').onclick = (e) => { switchView(getCurrentView(), VIEWS.waiting, 500, 500, () => { ipcRenderer.send(MSFT_OPCODE.OPEN_LOGIN, VIEWS.settings, VIEWS.settings) }) @@ -445,7 +445,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGIN, (_, ...arguments_) => { }) } } -}) +}) */ /** * Bind functionality for the account selection buttons. If another account @@ -511,7 +511,32 @@ let msAccDomElementCache * @param {Element} val The log out button element. * @param {boolean} isLastAccount If this logout is on the last added account. */ -function processLogOut(val, isLastAccount){ +function processLogOut(val, isLastAccount) { + const parent = val.closest('.settingsAuthAccount') + const uuid = parent.getAttribute('uuid') + const prevSelAcc = ConfigManager.getSelectedAccount() + const targetAcc = ConfigManager.getAuthAccount(uuid) + const accessToken = targetAcc.accessToken; + AuthManager.removeAzAuthAccount(uuid, accessToken).then(() => { + if(!isLastAccount && uuid === prevSelAcc.uuid){ + const selAcc = ConfigManager.getSelectedAccount() + refreshAuthAccountSelected(selAcc.uuid) + updateSelectedAccount(selAcc) + validateSelectedAccount() + } + if(isLastAccount) { + loginOptionsCancelEnabled(false) + loginOptionsViewOnLoginSuccess = VIEWS.settings + loginOptionsViewOnLoginCancel = VIEWS.loginOptions + switchView(getCurrentView(), VIEWS.loginOptions) + } + }) + $(parent).fadeOut(250, () => { + parent.remove() + }) +} + +/* function processLogOut(val, isLastAccount){ const parent = val.closest('.settingsAuthAccount') const uuid = parent.getAttribute('uuid') const prevSelAcc = ConfigManager.getSelectedAccount() @@ -598,7 +623,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => { }) } -}) +}) */ /** * Refreshes the status of the selected account on the auth account @@ -621,7 +646,7 @@ function refreshAuthAccountSelected(uuid){ }) } -const settingsCurrentMicrosoftAccounts = document.getElementById('settingsCurrentMicrosoftAccounts') +/*const settingsCurrentMicrosoftAccounts = document.getElementById('settingsCurrentMicrosoftAccounts')*/ const settingsCurrentMojangAccounts = document.getElementById('settingsCurrentMojangAccounts') /** @@ -635,7 +660,7 @@ function populateAuthAccounts(){ } const selectedUUID = ConfigManager.getSelectedAccount().uuid - let microsoftAuthAccountStr = '' + //let microsoftAuthAccountStr = '' let mojangAuthAccountStr = '' authKeys.forEach((val) => { @@ -643,7 +668,7 @@ function populateAuthAccounts(){ const accHtml = `
- ${acc.displayName} + ${acc.displayName}
@@ -665,15 +690,15 @@ function populateAuthAccounts(){
` - if(acc.type === 'microsoft') { + /**if(acc.type === 'microsoft') { microsoftAuthAccountStr += accHtml } else { mojangAuthAccountStr += accHtml - } - + }*/ + mojangAuthAccountStr += accHtml }) - settingsCurrentMicrosoftAccounts.innerHTML = microsoftAuthAccountStr + /**settingsCurrentMicrosoftAccounts.innerHTML = microsoftAuthAccountStr*/ settingsCurrentMojangAccounts.innerHTML = mojangAuthAccountStr } @@ -1404,10 +1429,10 @@ const settingsAboutChangelogText = settingsTabAbout.getElementsByClassName('se const settingsAboutChangelogButton = settingsTabAbout.getElementsByClassName('settingsChangelogButton')[0] // Bind the devtools toggle button. -document.getElementById('settingsAboutDevToolsButton').onclick = (e) => { +/**document.getElementById('settingsAboutDevToolsButton').onclick = (e) => { let window = remote.getCurrentWindow() window.toggleDevTools() -} +}*/ /** * Return whether or not the provided version is a prerelease. @@ -1455,7 +1480,7 @@ function populateAboutVersionInformation(){ */ function populateReleaseNotes(){ $.ajax({ - url: 'https://github.com/dscalzi/HeliosLauncher/releases.atom', + url: 'https://github.com/project-site-33/Site-33-Launcher/releases.atom', success: (data) => { const version = 'v' + remote.app.getVersion() const entries = $(data).find('entry') diff --git a/app/assets/js/scripts/uibinder.js b/app/assets/js/scripts/uibinder.js index 835e3c9d..2fe314b5 100644 --- a/app/assets/js/scripts/uibinder.js +++ b/app/assets/js/scripts/uibinder.js @@ -351,7 +351,7 @@ async function validateSelectedAccount(){ ) setOverlayHandler(() => { - const isMicrosoft = selectedAcc.type === 'microsoft' + /**const isMicrosoft = selectedAcc.type === 'microsoft' if(isMicrosoft) { // Empty for now @@ -360,7 +360,10 @@ async function validateSelectedAccount(){ // For convenience, pre-populate the username of the account. document.getElementById('loginUsername').value = selectedAcc.username validateEmail(selectedAcc.username) - } + }*/ + + document.getElementById('loginUsername').value = selectedAcc.username + validateEmail(selectedAcc.username) loginOptionsViewOnLoginSuccess = getCurrentView() loginOptionsViewOnLoginCancel = VIEWS.loginOptions @@ -368,7 +371,7 @@ async function validateSelectedAccount(){ if(accLen > 0) { loginOptionsViewOnCancel = getCurrentView() loginOptionsViewCancelHandler = () => { - if(isMicrosoft) { + /*if(isMicrosoft) { ConfigManager.addMicrosoftAuthAccount( selectedAcc.uuid, selectedAcc.accessToken, @@ -380,7 +383,8 @@ async function validateSelectedAccount(){ ) } else { ConfigManager.addMojangAuthAccount(selectedAcc.uuid, selectedAcc.accessToken, selectedAcc.username, selectedAcc.displayName) - } + }*/ + ConfigManager.addAzAuthAccount(selectedAcc.uuid, selectedAcc.accessToken, selectedAcc.username, selectedAcc.displayName) ConfigManager.save() validateSelectedAccount() } diff --git a/app/frame.ejs b/app/frame.ejs index c2aaf337..89c17a86 100644 --- a/app/frame.ejs +++ b/app/frame.ejs @@ -13,7 +13,7 @@ <% } else{ %>
- Helios Launcher + Site-33 Launcher
- - MINECRAFT LOGIN + + Site-33 Login
@@ -16,7 +16,7 @@ * Invalid Value - +
@@ -25,15 +25,24 @@ * Required - + +
+
+ + + + + + Si A2F actif +
- forgot password? + Mot de passe oublié?
@@ -54,10 +63,10 @@
- Need an Account? + Pas encore inscrit ? -

Your password is sent directly to mojang and never stored.

-

Helios Launcher is not affiliated with Mojang AB.

+

Votre mot de passe est envoyé directement a notre site.

+

Site-33 n'est pas affilié à mojang ab.

diff --git a/app/loginOptions.ejs b/app/loginOptions.ejs index 36af37e0..679a31e3 100644 --- a/app/loginOptions.ejs +++ b/app/loginOptions.ejs @@ -3,7 +3,7 @@

Login Options

-
+
diff --git a/app/settings.ejs b/app/settings.ejs index aa1fa764..6c725ce0 100644 --- a/app/settings.ejs +++ b/app/settings.ejs @@ -28,7 +28,7 @@ Account Settings Add new accounts or manage existing ones.
-
+ -
-
+
@@ -57,10 +57,10 @@ - Mojang + Site
- +
@@ -71,11 +71,11 @@