diff --git a/controllers/webauthn.go b/controllers/webauthn.go index d48a6396..b364f635 100644 --- a/controllers/webauthn.go +++ b/controllers/webauthn.go @@ -121,6 +121,7 @@ func (c *ApiController) WebAuthnSigninBegin() { // @Success 200 {object} Response "The Response object" // @router /webauthn/signin/finish [post] func (c *ApiController) WebAuthnSigninFinish() { + responseType := c.Input().Get("responseType") webauthnObj := object.GetWebAuthnObject(c.Ctx.Request.Host) sessionObj := c.GetSession("authentication") sessionData, ok := sessionObj.(webauthn.SessionData) @@ -138,5 +139,11 @@ func (c *ApiController) WebAuthnSigninFinish() { } c.SetSessionUsername(userId) util.LogInfo(c.Ctx, "API: [%s] signed in", userId) - c.ResponseOk(userId) + + application := object.GetApplicationByUser(user) + var form RequestForm + form.Type = responseType + resp := c.HandleLoggedIn(application, user, &form) + c.Data["json"] = resp + c.ServeJSON() } diff --git a/web/src/auth/AuthBackend.js b/web/src/auth/AuthBackend.js index 0961edc5..e1e1fee9 100644 --- a/web/src/auth/AuthBackend.js +++ b/web/src/auth/AuthBackend.js @@ -37,7 +37,7 @@ export function getEmailAndPhone(values) { }).then((res) => res.json()); } -function oAuthParamsToQuery(oAuthParams) { +export function oAuthParamsToQuery(oAuthParams) { // login if (oAuthParams === null) { return ""; diff --git a/web/src/auth/LoginPage.js b/web/src/auth/LoginPage.js index c3eb69a0..aa01be9b 100644 --- a/web/src/auth/LoginPage.js +++ b/web/src/auth/LoginPage.js @@ -599,7 +599,7 @@ class LoginPage extends React.Component { const rawId = assertion.rawId; const sig = assertion.response.signature; const userHandle = assertion.response.userHandle; - return fetch(`${Setting.ServerUrl}/api/webauthn/signin/finish`, { + return fetch(`${Setting.ServerUrl}/api/webauthn/signin/finish${AuthBackend.oAuthParamsToQuery(oAuthParams)}`, { method: "POST", credentials: "include", body: JSON.stringify({