0

I'm trying to make a wordpress auth based on discord API. I'm actually verifying if the user was from a group on a discord server. I've done this part of the script in node.js and OAuth2 (part of the discord API). This part works fine.

But I got some problem with the wordpress auth. I've plan to use a unique account for all the user. Because I don't need a huge security, the website is juste a wiki about (knowledge website). I'm trying de log theme automatically by auth cookie. I want to reproduce the "wp_generate_auth_cookie" from the "wp-includes/pluggable.php" file but I'm in sstruggle with the hash part. I don't know how to reproduce the hash part.

I've see this post, but that don't really help me. I'm not a advanced user of node.js : Wordpress authentication in node.js

I don't know if it was the easiest way. If you have a another way, I'm open to your suggestion.

Thanks in advance for your help.

5
  • Although this isn't the answer you are looking for, I would recommend not trying to reproduce wp_generate_auth_cookie. First, that function is pluggable which means other implementations might tweak/replace it, something I've personally done, too. Second, do you have a token manager, too? You'll need that for this. Third, you'll have to replicate wp_hash, wp_salt and wp_generate_password, and possibly more. Instead, WordPress has a REST API that you should be able to use. Have your JS code talk to that and keep the WordPress stuff inside of WordPress. Commented Mar 29, 2021 at 17:28
  • @ChrisHaas I'm open to everything ! I will take a look closer at the rest API. I've seen this option but I was thinking that would be easier with the idea I've exposed upper. Thanks for your suggestion ! Commented Mar 30, 2021 at 16:10
  • @ChrisHaas Btw if you have some advice to do it, I will take it with pleasure 😉 Commented Mar 30, 2021 at 16:34
  • I guess I still don't 100% know what you are trying to do. Do you want to sign into Discord using WordPress credentials, sign into WordPress using Discord credentials, duplicate a user in Discord and WordPress and ensure that the passwords are synced, or perform SSO somehow? As that post talks about, each can be solved in different ways, so if you can clarify that, that might help. Commented Mar 30, 2021 at 17:39
  • Hello @ChrisHaas, My user sign into discord. Our node.js script verify if he belongs to a defined group. Then if he belongs to the group I want to sign it into the site throw a generic account Commented Apr 1, 2021 at 13:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.