如何使用OAuth和门卫存储会话数据?

时间:2023-01-16 15:18:48

Is there uniform way of storing user settings that would be bound to particular OAuth token using doorkeeper gem (or OAuth in general)?

是否存在使用门卫gem(或一般OAuth)存储将绑定到特定OAuth令牌的用户设置的统一方式?

I'd like user to choose locale when logging in, that would be kept as long as the same token is used. In my use case I want settings to be session-specific instead user-specific -- multiple tokens can be issued to single resource owner, and have different settings.

我希望用户在登录时选择区域设置,只要使用相同的令牌,就会保留。在我的用例中,我希望设置是特定于会话的,而不是特定于用户的 - 可以向单个资源所有者发出多个令牌,并具有不同的设置。

1 个解决方案

#1


0  

One way would be to create a Preference model that would have an oauth_token and a user_id field. When your User sets a preference, a Preference is created, using the oauth_token and user_id along with whatever data is involved in their preference, in this case you'd have three fields in your Preferences table:

一种方法是创建一个具有oauth_token和user_id字段的Preference模型。当您的用户设置首选项时,会使用oauth_token和user_id以及他们的首选项中涉及的任何数据创建首选项,在这种情况下,您的Preferences表中有三个字段:

oauth_token:string, user_id:integer and locale:string

oauth_token:string,user_id:integer和locale:string

When a user logs on, the current_user.token can be used to match with the oauth field in your Preferences and then you can load the preferences.

当用户登录时,current_user.token可用于与首选项中的oauth字段匹配,然后您可以加载首选项。

#1


0  

One way would be to create a Preference model that would have an oauth_token and a user_id field. When your User sets a preference, a Preference is created, using the oauth_token and user_id along with whatever data is involved in their preference, in this case you'd have three fields in your Preferences table:

一种方法是创建一个具有oauth_token和user_id字段的Preference模型。当您的用户设置首选项时,会使用oauth_token和user_id以及他们的首选项中涉及的任何数据创建首选项,在这种情况下,您的Preferences表中有三个字段:

oauth_token:string, user_id:integer and locale:string

oauth_token:string,user_id:integer和locale:string

When a user logs on, the current_user.token can be used to match with the oauth field in your Preferences and then you can load the preferences.

当用户登录时,current_user.token可用于与首选项中的oauth字段匹配,然后您可以加载首选项。