@baris I'm also trying this and it works with SSO also. However now I can't logout and use /login?local=1 to log the admin account as above method force only use /login and it use the sso. Any clue, hint to avoid this?
I use the code in here
https://github.com/LM1LC3N7/nodebb-plugin-private-forum/blob/master/library.js