Skip to content

Commit 831d34a

Browse files
Kamesutasan-antonio0978
authored andcommitted
Localize Microsoft/Mojang authentication error messages (dscalzi#331)
* Move Microsoft/Mojang error message to lang file. * Add mstfLogin to language file
1 parent 49b744c commit 831d34a

File tree

2 files changed

+159
-2
lines changed

2 files changed

+159
-2
lines changed

app/assets/js/authmanager.js

+112-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,122 @@
1212
const ConfigManager = require('./configmanager')
1313
const { LoggerUtil } = require('helios-core')
1414
const { RestResponseStatus } = require('helios-core/common')
15-
const { MojangRestAPI, mojangErrorDisplayable, MojangErrorCode } = require('helios-core/mojang')
16-
const { MicrosoftAuth, microsoftErrorDisplayable, MicrosoftErrorCode } = require('helios-core/microsoft')
15+
const { MojangRestAPI, MojangErrorCode } = require('helios-core/mojang')
16+
const { MicrosoftAuth, MicrosoftErrorCode } = require('helios-core/microsoft')
1717
const { AZURE_CLIENT_ID } = require('./ipcconstants')
18+
const Lang = require('./langloader')
1819

1920
const log = LoggerUtil.getLogger('AuthManager')
2021

22+
// Error messages
23+
24+
function microsoftErrorDisplayable(errorCode) {
25+
switch (errorCode) {
26+
case MicrosoftErrorCode.NO_PROFILE:
27+
return {
28+
title: Lang.queryJS('auth.microsoft.error.noProfileTitle'),
29+
desc: Lang.queryJS('auth.microsoft.error.noProfileDesc')
30+
}
31+
case MicrosoftErrorCode.NO_XBOX_ACCOUNT:
32+
return {
33+
title: Lang.queryJS('auth.microsoft.error.noXboxAccountTitle'),
34+
desc: Lang.queryJS('auth.microsoft.error.noXboxAccountDesc')
35+
}
36+
case MicrosoftErrorCode.XBL_BANNED:
37+
return {
38+
title: Lang.queryJS('auth.microsoft.error.xblBannedTitle'),
39+
desc: Lang.queryJS('auth.microsoft.error.xblBannedDesc')
40+
}
41+
case MicrosoftErrorCode.UNDER_18:
42+
return {
43+
title: Lang.queryJS('auth.microsoft.error.under18Title'),
44+
desc: Lang.queryJS('auth.microsoft.error.under18Desc')
45+
}
46+
case MicrosoftErrorCode.UNKNOWN:
47+
return {
48+
title: Lang.queryJS('auth.microsoft.error.unknownTitle'),
49+
desc: Lang.queryJS('auth.microsoft.error.unknownDesc')
50+
}
51+
}
52+
}
53+
54+
function mojangErrorDisplayable(errorCode) {
55+
switch(errorCode) {
56+
case MojangErrorCode.ERROR_METHOD_NOT_ALLOWED:
57+
return {
58+
title: Lang.queryJS('auth.mojang.error.methodNotAllowedTitle'),
59+
desc: Lang.queryJS('auth.mojang.error.methodNotAllowedDesc')
60+
}
61+
case MojangErrorCode.ERROR_NOT_FOUND:
62+
return {
63+
title: Lang.queryJS('auth.mojang.error.notFoundTitle'),
64+
desc: Lang.queryJS('auth.mojang.error.notFoundDesc')
65+
}
66+
case MojangErrorCode.ERROR_USER_MIGRATED:
67+
return {
68+
title: Lang.queryJS('auth.mojang.error.accountMigratedTitle'),
69+
desc: Lang.queryJS('auth.mojang.error.accountMigratedDesc')
70+
}
71+
case MojangErrorCode.ERROR_INVALID_CREDENTIALS:
72+
return {
73+
title: Lang.queryJS('auth.mojang.error.invalidCredentialsTitle'),
74+
desc: Lang.queryJS('auth.mojang.error.invalidCredentialsDesc')
75+
}
76+
case MojangErrorCode.ERROR_RATELIMIT:
77+
return {
78+
title: Lang.queryJS('auth.mojang.error.tooManyAttemptsTitle'),
79+
desc: Lang.queryJS('auth.mojang.error.tooManyAttemptsDesc')
80+
}
81+
case MojangErrorCode.ERROR_INVALID_TOKEN:
82+
return {
83+
title: Lang.queryJS('auth.mojang.error.invalidTokenTitle'),
84+
desc: Lang.queryJS('auth.mojang.error.invalidTokenDesc')
85+
}
86+
case MojangErrorCode.ERROR_ACCESS_TOKEN_HAS_PROFILE:
87+
return {
88+
title: Lang.queryJS('auth.mojang.error.tokenHasProfileTitle'),
89+
desc: Lang.queryJS('auth.mojang.error.tokenHasProfileDesc')
90+
}
91+
case MojangErrorCode.ERROR_CREDENTIALS_MISSING:
92+
return {
93+
title: Lang.queryJS('auth.mojang.error.credentialsMissingTitle'),
94+
desc: Lang.queryJS('auth.mojang.error.credentialsMissingDesc')
95+
}
96+
case MojangErrorCode.ERROR_INVALID_SALT_VERSION:
97+
return {
98+
title: Lang.queryJS('auth.mojang.error.invalidSaltVersionTitle'),
99+
desc: Lang.queryJS('auth.mojang.error.invalidSaltVersionDesc')
100+
}
101+
case MojangErrorCode.ERROR_UNSUPPORTED_MEDIA_TYPE:
102+
return {
103+
title: Lang.queryJS('auth.mojang.error.unsupportedMediaTypeTitle'),
104+
desc: Lang.queryJS('auth.mojang.error.unsupportedMediaTypeDesc')
105+
}
106+
case MojangErrorCode.ERROR_GONE:
107+
return {
108+
title: Lang.queryJS('auth.mojang.error.accountGoneTitle'),
109+
desc: Lang.queryJS('auth.mojang.error.accountGoneDesc')
110+
}
111+
case MojangErrorCode.ERROR_UNREACHABLE:
112+
return {
113+
title: Lang.queryJS('auth.mojang.error.unreachableTitle'),
114+
desc: Lang.queryJS('auth.mojang.error.unreachableDesc')
115+
}
116+
case MojangErrorCode.ERROR_NOT_PAID:
117+
return {
118+
title: Lang.queryJS('auth.mojang.error.gameNotPurchasedTitle'),
119+
desc: Lang.queryJS('auth.mojang.error.gameNotPurchasedDesc')
120+
}
121+
case MojangErrorCode.UNKNOWN:
122+
return {
123+
title: Lang.queryJS('auth.mojang.error.unknownErrorTitle'),
124+
desc: Lang.queryJS('auth.mojang.error.unknownErrorDesc')
125+
}
126+
default:
127+
throw new Error(`Unknown error code: ${errorCode}`)
128+
}
129+
}
130+
21131
// Functions
22132

23133
/**

app/assets/lang/en_US.toml

+47
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,11 @@ latestVersionTitle = "You Are Running the Latest Version"
279279
checkForUpdatesButton = "Check for Updates"
280280
checkingForUpdatesButton = "Checking for Updates.."
281281

282+
[js.settings.msftLogin]
283+
errorTitle = "Microsoft Login Failed"
284+
errorMessage = "We were unable to authenticate your Microsoft account. Please try again."
285+
okButton = "OK"
286+
282287
[js.uibinder.startup]
283288
fatalErrorTitle = "Fatal Error: Unable to Load Distribution Index"
284289
fatalErrorMessage = "A connection could not be established to our servers to download the distribution index. No local copies were available to load. <br><br>The distribution index is an essential file which provides the latest server information. The launcher is unable to start without it. Ensure you are connected to the internet and relaunch the application."
@@ -295,3 +300,45 @@ selectAnotherAccountButton = "Select Another Account"
295300
checkingForUpdateButton = "Checking for Updates..."
296301
installNowButton = "Install Now"
297302
checkForUpdatesButton = "Check for Updates"
303+
304+
[js.auth.microsoft.error]
305+
noProfileTitle = "Error During Login:<br>Profile Not Set Up"
306+
noProfileDesc = "Your Microsoft account does not yet have a Minecraft profile set up. If you have recently purchased the game or redeemed it through Xbox Game Pass, you have to set up your profile on <a href=\"https://minecraft.net/\">Minecraft.net</a>.<br><br>If you have not yet purchased the game, you can also do that on <a href=\"https://minecraft.net/\">Minecraft.net</a>."
307+
noXboxAccountTitle = "Error During Login:<br>No Xbox Account"
308+
noXboxAccountDesc = "Your Microsoft account has no Xbox account associated with it."
309+
xblBannedTitle = "Error During Login:<br>Xbox Live Unavailable"
310+
xblBannedDesc = "Your Microsoft account is from a country where Xbox Live is not available or banned."
311+
under18Title = "Error During Login:<br>Parental Approval Required"
312+
under18Desc = "Accounts for users under the age of 18 must be added to a Family by an adult."
313+
unknownTitle = "Unknown Error During Login"
314+
unknownDesc = "An unknown error has occurred. Please see the console for details."
315+
316+
[js.auth.mojang.error]
317+
methodNotAllowedTitle = "Internal Error:<br>Method Not Allowed"
318+
methodNotAllowedDesc = "Method not allowed. Please report this error."
319+
notFoundTitle = "Internal Error:<br>Not Found"
320+
notFoundDesc = "The authentication endpoint was not found. Please report this issue."
321+
accountMigratedTitle = "Error During Login:<br>Account Migrated"
322+
accountMigratedDesc = "You've attempted to login with a migrated account. Try again using the account email as the username."
323+
invalidCredentialsTitle = "Error During Login:<br>Invalid Credentials"
324+
invalidCredentialsDesc = "The email or password you've entered is incorrect. Please try again."
325+
tooManyAttemptsTitle = "Error During Login:<br>Too Many Attempts"
326+
tooManyAttemptsDesc = "There have been too many login attempts with this account recently. Please try again later."
327+
invalidTokenTitle = "Error During Login:<br>Invalid Token"
328+
invalidTokenDesc = "The provided access token is invalid."
329+
tokenHasProfileTitle = "Error During Login:<br>Token Has Profile"
330+
tokenHasProfileDesc = "Access token already has a profile assigned. Selecting profiles is not implemented yet."
331+
credentialsMissingTitle = "Error During Login:<br>Credentials Missing"
332+
credentialsMissingDesc = "Username/password was not submitted or password is less than 3 characters."
333+
invalidSaltVersionTitle = "Error During Login:<br>Invalid Salt Version"
334+
invalidSaltVersionDesc = "Invalid salt version."
335+
unsupportedMediaTypeTitle = "Internal Error:<br>Unsupported Media Type"
336+
unsupportedMediaTypeDesc = "Unsupported media type. Please report this error."
337+
accountGoneTitle = "Error During Login:<br>Account Migrated"
338+
accountGoneDesc = "Account has been migrated to a Microsoft account. Please log in with Microsoft."
339+
unreachableTitle = "Error During Login:<br>Unreachable"
340+
unreachableDesc = "Unable to reach the authentication servers. Ensure that they are online and you are connected to the internet."
341+
gameNotPurchasedTitle = "Error During Login:<br>Game Not Purchased"
342+
gameNotPurchasedDesc = "The account you are trying to login with has not purchased a copy of Minecraft. You may purchase a copy on <a href=\"https://minecraft.net/\">Minecraft.net</a>"
343+
unknownErrorTitle = "Unknown Error During Login"
344+
unknownErrorDesc = "An unknown error has occurred. Please see the console for details."

0 commit comments

Comments
 (0)