File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,9 @@ import { createElement } from 'react'
2222
2323export { OAuthButton , oAuthPluginOptions }
2424
25- interface User { }
25+ interface User {
26+ id : string | number
27+ }
2628
2729const log = debug ( 'plugin:oauth' )
2830
@@ -173,6 +175,14 @@ function oAuthPluginServer(
173175
174176 if ( users . docs && users . docs . length ) {
175177 user = users . docs [ 0 ]
178+ if ( options . updateOnLogin ) {
179+ user = await payload . update ( {
180+ collection : collectionSlug ,
181+ id : user . id ,
182+ data : info ,
183+ showHiddenFields : true ,
184+ } )
185+ }
176186 user . collection = collectionSlug
177187 user . _strategy = strategyName
178188 } else {
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ export interface oAuthPluginOptions extends StrategyOptions {
7171 * @default /admin
7272 */
7373 successRedirect ?: string
74+
75+ /**
76+ * Boolean to allow updating users on login
77+ * @default false
78+ */
79+ updateOnLogin ?: boolean
7480}
7581
7682export type ButtonProps = {
You can’t perform that action at this time.
0 commit comments