@@ -48,6 +48,7 @@ const plugin = {
4848 adminRevalidate : 'off' ,
4949 noRegistration : 'off' ,
5050 payloadParent : undefined ,
51+ allowBannedUsers : false ,
5152 } ,
5253} ;
5354
@@ -72,7 +73,7 @@ plugin.init = async (params) => {
7273 await plugin . reloadSettings ( ) ;
7374} ;
7475
75- plugin . appendConfig = async ( config ) {
76+ plugin . appendConfig = async ( config ) => {
7677 config . sessionSharing = {
7778 logoutRedirect : plugin . settings . logoutRedirect ,
7879 loginOverride : plugin . settings . loginOverride ,
@@ -99,7 +100,7 @@ SocketPlugins.sessionSharing.showUserIds = async (socket, data) => {
99100 return Promise . all ( uids . map ( async ( uid ) => db . getSortedSetRangeByScore ( plugin . settings . name + ':uid' , 0 , - 1 , uid , uid ) ) ) ;
100101} ;
101102
102- SocketPlugins . sessionSharing . showUserIds = async ( socket , data ) {
103+ SocketPlugins . sessionSharing . showUserIds = async ( socket , data ) => {
103104 // Retrieve the hash and find matches
104105 const { uids } = data ;
105106
@@ -110,7 +111,7 @@ SocketPlugins.sessionSharing.showUserIds = async (socket, data) {
110111 return Promise . all ( uids . map ( async ( uid ) => db . getSortedSetRangeByScore ( plugin . settings . name + ':uid' , 0 , - 1 , uid , uid ) ) ) ;
111112} ;
112113
113- SocketPlugins . sessionSharing . findUserByRemoteId = async ( socket , data ) {
114+ SocketPlugins . sessionSharing . findUserByRemoteId = async ( socket , data ) => {
114115 if ( ! data . remoteId ) {
115116 throw new Error ( 'no-remote-id-supplied' ) ;
116117 }
@@ -143,7 +144,7 @@ plugin.process = async (token) => {
143144 return uid ;
144145} ;
145146
146- plugin . normalizePayload = async ( payload ) {
147+ plugin . normalizePayload = async ( payload ) => {
147148 const userData = { } ;
148149
149150 if ( plugin . settings . payloadParent ) {
@@ -201,9 +202,17 @@ plugin.verifyUser = async (token, uid, isNewUser) => {
201202 isNewUser : isNewUser ,
202203 token : token ,
203204 } ) ;
205+
206+ // Check ban state of user
207+ const isBanned = await user . bans . isBanned ( uid ) ;
208+
209+ // Reject if banned and settings dont allow banned users to login
210+ if ( isBanned && ! plugin . settings . allowBannedUsers ) {
211+ throw new Error ( 'banned' ) ;
212+ }
204213} ;
205214
206- plugin . findOrCreateUser = async ( userData ) {
215+ plugin . findOrCreateUser = async ( userData ) => {
207216 const { id } = userData ;
208217 let isNewUser = false ;
209218 let userId = null ;
@@ -255,7 +264,7 @@ plugin.findOrCreateUser = async (userData) {
255264 return [ userId , isNewUser ] ;
256265} ;
257266
258- plugin . updateUserProfile = async ( uid , userData , isNewUser ) {
267+ plugin . updateUserProfile = async ( uid , userData , isNewUser ) => {
259268 winston . debug ( 'consider updateProfile?' , isNewUser || plugin . settings . updateProfile === 'on' ) ;
260269 let userObj = { } ;
261270
@@ -293,7 +302,7 @@ plugin.updateUserProfile = async (uid, userData, isNewUser) {
293302 }
294303} ;
295304
296- plugin . updateUserGroups = async ( uid , userData , isNewUser ) {
305+ plugin . updateUserGroups = async ( uid , userData , isNewUser ) => {
297306 if ( ! userData . groups || ! Array . isArray ( userData . groups ) ) {
298307 return ;
299308 }
@@ -343,7 +352,7 @@ async function executeJoinLeave(uid, join, leave) {
343352 ] ) ;
344353}
345354
346- plugin . createUser = async ( userData ) {
355+ plugin . createUser = async ( userData ) => {
347356 winston . verbose ( '[session-sharing] No user found, creating a new user for this login' ) ;
348357
349358 const uid = await user . create ( _ . pick ( userData , profileFields ) ) ;
@@ -485,7 +494,7 @@ plugin.addMiddleware = async function (req, res, next) {
485494 }
486495} ;
487496
488- plugin . cleanup = async ( data ) {
497+ plugin . cleanup = async ( data ) => {
489498 if ( plugin . settings . cookieDomain ) {
490499 winston . verbose ( '[session-sharing] Clearing cookie' ) ;
491500 data . res . clearCookie ( plugin . settings . cookieName , {
@@ -530,7 +539,7 @@ plugin.generate = function (req, res) {
530539 res . sendStatus ( 200 ) ;
531540} ;
532541
533- plugin . addAdminNavigation = async ( header ) {
542+ plugin . addAdminNavigation = async ( header ) => {
534543 header . plugins . push ( {
535544 route : '/plugins/session-sharing' ,
536545 icon : 'fa-user-secret' ,
0 commit comments