Cardata: display oauth user code (#25818)
This commit is contained in:
parent
157f9d207c
commit
c5fc4b4f99
28 changed files with 993 additions and 220 deletions
|
|
@ -18,7 +18,9 @@ type errorResponse struct {
|
|||
}
|
||||
|
||||
type loginResponse struct {
|
||||
LoginUri string `json:"loginUri"`
|
||||
LoginUri string `json:"loginUri"`
|
||||
Code string `json:"code,omitempty"`
|
||||
Expiry *time.Time `json:"expiry,omitempty"`
|
||||
}
|
||||
|
||||
// jsonWrite writes a JSON response
|
||||
|
|
@ -104,13 +106,27 @@ func (a *Handler) handleLogin(w http.ResponseWriter, r *http.Request) {
|
|||
delete(a.states, encryptedState)
|
||||
})
|
||||
|
||||
uri, err := provider.Login(encryptedState)
|
||||
uri, da, err := provider.Login(encryptedState)
|
||||
if err != nil {
|
||||
jsonError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
jsonWrite(w, loginResponse{LoginUri: uri})
|
||||
res := loginResponse{
|
||||
LoginUri: uri,
|
||||
}
|
||||
|
||||
if da != nil {
|
||||
res.Expiry = &da.Expiry
|
||||
if da.VerificationURIComplete != "" {
|
||||
res.LoginUri = da.VerificationURIComplete
|
||||
} else {
|
||||
res.LoginUri = da.VerificationURI
|
||||
res.Code = da.UserCode
|
||||
}
|
||||
}
|
||||
|
||||
jsonWrite(w, res)
|
||||
}
|
||||
|
||||
func (a *Handler) handleLogout(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue