Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change access tokens into a post type. #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spacedmonkey
Copy link
Collaborator

Moving access tokens to a post type makes a lot of sense. It means they are deleted when the user is deleted.

There are some backwards compatablity issues, but I believe I have done a good job in fixing these, by support the old options and copying them over to post type.

Fixes #215

@schlessera
Copy link
Member

Did you also consider user meta for this?

@dshanske
Copy link

dshanske commented Jun 18, 2018

The Oauth2 plugin uses user meta. It gave me the idea to use it in my Indieauth plugin code

@spacedmonkey
Copy link
Collaborator Author

@schlessera @dshanske I looked in it doing that, but I couldn't find a way to do it.

There is a method called get_access_token which is used to get the access token from options. The token is passed here as the user id is not yet known. Using user meta isn't possible as, it is not easy (without raw SQL queries or by doing a meta query of users ) to get user id via the meta key.

Using posts, isn't something I love, but it a type that allows for lookup via token (post_name / slug) and by user (post_author).

Post related to users also delete with the users, which is a nice bit of tidying up, that the current implementation doesn't do.

I am sure it maybe possible to refactor the code to use user_meta and it would mean a much longer change than is really required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store access tokens as a post type
3 participants