mbkauthe 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/lib/config.js +1 -0
- package/lib/main.js +16 -16
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,7 +16,7 @@ if (process.env.test === "dev") {
|
|
|
16
16
|
app.use(router);
|
|
17
17
|
app.use((req, res) => {
|
|
18
18
|
console.log(`Path not found: ${req.method} ${req.url}`);
|
|
19
|
-
return res
|
|
19
|
+
return renderError(res, {
|
|
20
20
|
layout: false,
|
|
21
21
|
code: 404,
|
|
22
22
|
error: "Not Found",
|
package/lib/config.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -776,13 +776,13 @@ router.get('/mbkauthe/api/github/login', GitHubOAuthLimit, (req, res, next) => {
|
|
|
776
776
|
passport.authenticate('github-login')(req, res, next);
|
|
777
777
|
}
|
|
778
778
|
else {
|
|
779
|
-
return
|
|
779
|
+
return renderError(res, {
|
|
780
780
|
code: '403',
|
|
781
781
|
error: 'GitHub Login Disabled',
|
|
782
782
|
message: 'GitHub login is currently disabled. Please use your username and password to log in.',
|
|
783
783
|
page: '/mbkauthe/login',
|
|
784
784
|
pagename: 'Login',
|
|
785
|
-
})
|
|
785
|
+
});
|
|
786
786
|
}
|
|
787
787
|
});
|
|
788
788
|
|
|
@@ -800,53 +800,53 @@ router.get('/mbkauthe/api/github/login/callback',
|
|
|
800
800
|
// Map error codes to user-friendly messages
|
|
801
801
|
switch (err.code) {
|
|
802
802
|
case 'GITHUB_NOT_LINKED':
|
|
803
|
-
return
|
|
803
|
+
return renderError(res, {
|
|
804
804
|
code: '403',
|
|
805
805
|
error: 'GitHub Account Not Linked',
|
|
806
806
|
message: 'Your GitHub account is not linked to any user in our system. To link your GitHub account, a User must connect their GitHub account to mbktech account through the user settings.',
|
|
807
807
|
page: '/mbkauthe/login',
|
|
808
808
|
pagename: 'Login'
|
|
809
|
-
})
|
|
809
|
+
});
|
|
810
810
|
|
|
811
811
|
case 'ACCOUNT_INACTIVE':
|
|
812
|
-
return
|
|
812
|
+
return renderError(res, {
|
|
813
813
|
code: '403',
|
|
814
814
|
error: 'Account Inactive',
|
|
815
815
|
message: 'Your account has been deactivated. Please contact your administrator.',
|
|
816
816
|
page: '/mbkauthe/login',
|
|
817
817
|
pagename: 'Login'
|
|
818
|
-
})
|
|
818
|
+
});
|
|
819
819
|
|
|
820
820
|
case 'NOT_AUTHORIZED':
|
|
821
|
-
return
|
|
821
|
+
return renderError(res, {
|
|
822
822
|
code: '403',
|
|
823
823
|
error: 'Not Authorized',
|
|
824
824
|
message: `You are not authorized to access ${mbkautheVar.APP_NAME}. Please contact your administrator.`,
|
|
825
825
|
page: '/mbkauthe/login',
|
|
826
826
|
pagename: 'Login'
|
|
827
|
-
})
|
|
827
|
+
});
|
|
828
828
|
|
|
829
829
|
default:
|
|
830
|
-
return
|
|
830
|
+
return renderError(res, {
|
|
831
831
|
code: '500',
|
|
832
832
|
error: 'Authentication Error',
|
|
833
833
|
message: 'An error occurred during GitHub authentication. Please try again.',
|
|
834
834
|
page: '/mbkauthe/login',
|
|
835
835
|
pagename: 'Login',
|
|
836
836
|
details: process.env.NODE_ENV === 'development' ? `${err.message}\n${err.stack}` : 'Error details hidden in production'
|
|
837
|
-
})
|
|
837
|
+
});
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
840
|
|
|
841
841
|
if (!user) {
|
|
842
842
|
console.error('[mbkauthe] GitHub callback: No user data received');
|
|
843
|
-
return
|
|
843
|
+
return renderError(res, {
|
|
844
844
|
code: '401',
|
|
845
845
|
error: 'Authentication Failed',
|
|
846
846
|
message: 'GitHub authentication failed. Please try again.',
|
|
847
847
|
page: '/mbkauthe/login',
|
|
848
848
|
pagename: 'Login'
|
|
849
|
-
})
|
|
849
|
+
});
|
|
850
850
|
}
|
|
851
851
|
|
|
852
852
|
// Authentication successful, attach user to request
|
|
@@ -874,14 +874,14 @@ router.get('/mbkauthe/api/github/login/callback',
|
|
|
874
874
|
|
|
875
875
|
if (userResult.rows.length === 0) {
|
|
876
876
|
console.error(`[mbkauthe] GitHub login: User not found: ${githubUser.username}`);
|
|
877
|
-
return
|
|
877
|
+
return renderError(res, {
|
|
878
878
|
code: '404',
|
|
879
879
|
error: 'User Not Found',
|
|
880
880
|
message: 'Your GitHub account is linked, but the user account no longer exists in our system.',
|
|
881
881
|
page: '/mbkauthe/login',
|
|
882
882
|
pagename: 'Login',
|
|
883
883
|
details: `GitHub username: ${githubUser.username}\nPlease contact your administrator.`
|
|
884
|
-
})
|
|
884
|
+
});
|
|
885
885
|
}
|
|
886
886
|
|
|
887
887
|
const user = userResult.rows[0];
|
|
@@ -946,14 +946,14 @@ router.get('/mbkauthe/api/github/login/callback',
|
|
|
946
946
|
|
|
947
947
|
} catch (err) {
|
|
948
948
|
console.error('[mbkauthe] GitHub login callback error:', err);
|
|
949
|
-
return
|
|
949
|
+
return renderError(res, {
|
|
950
950
|
code: '500',
|
|
951
951
|
error: 'Internal Server Error',
|
|
952
952
|
message: 'An error occurred during GitHub authentication. Please try again.',
|
|
953
953
|
page: '/mbkauthe/login',
|
|
954
954
|
pagename: 'Login',
|
|
955
955
|
details: process.env.NODE_ENV === 'development' ? `${err.message}\n${err.stack}` : 'Error details hidden in production'
|
|
956
|
-
})
|
|
956
|
+
});
|
|
957
957
|
}
|
|
958
958
|
}
|
|
959
959
|
);
|