From 6d0303deaf64a139cfaed78f0dd5785ece551c45 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Thu, 18 May 2023 00:19:36 +0300 Subject: [PATCH] added meta.isNew to the json OAuth2 auth response --- CHANGELOG.md | 2 ++ apis/record_auth.go | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82dfbf53..0610edeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ - Added support for multiple relations sort in the Admin UI. +- Added `meta.isNew` to the OAuth2 auth JSON response to indicate newly created PocketBase user. + ## v0.15.3 diff --git a/apis/record_auth.go b/apis/record_auth.go index 66cda695..9e626c12 100644 --- a/apis/record_auth.go +++ b/apis/record_auth.go @@ -242,7 +242,15 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error { e.Record = data.Record e.OAuth2User = data.OAuth2User - return RecordAuthResponse(api.app, e.HttpContext, e.Record, e.OAuth2User) + meta := struct { + *auth.AuthUser + IsNew bool `json:"isNew"` + }{ + AuthUser: e.OAuth2User, + IsNew: event.IsNewRecord, + } + + return RecordAuthResponse(api.app, e.HttpContext, e.Record, meta) }) } })