(w http.ResponseWriter, r *http.Request, params *VerifyParams)
| 118 | } |
| 119 | |
| 120 | func (a *API) verifyGet(w http.ResponseWriter, r *http.Request, params *VerifyParams) error { |
| 121 | ctx := r.Context() |
| 122 | db := a.db.WithContext(ctx) |
| 123 | |
| 124 | var ( |
| 125 | user *models.User |
| 126 | grantParams models.GrantParams |
| 127 | err error |
| 128 | token *AccessTokenResponse |
| 129 | authCode string |
| 130 | rurl string |
| 131 | ) |
| 132 | |
| 133 | grantParams.FillGrantParams(r) |
| 134 | |
| 135 | flowType := models.ImplicitFlow |
| 136 | var authenticationMethod models.AuthenticationMethod |
| 137 | if strings.HasPrefix(params.Token, PKCEPrefix) { |
| 138 | flowType = models.PKCEFlow |
| 139 | authenticationMethod, err = models.ParseAuthenticationMethod(params.Type) |
| 140 | if err != nil { |
| 141 | return err |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | err = db.Transaction(func(tx *storage.Connection) error { |
| 146 | var terr error |
| 147 | user, terr = a.verifyTokenHash(tx, params) |
| 148 | if terr != nil { |
| 149 | return terr |
| 150 | } |
| 151 | switch params.Type { |
| 152 | case mail.SignupVerification, mail.InviteVerification: |
| 153 | user, terr = a.signupVerify(r, ctx, tx, user) |
| 154 | case mail.RecoveryVerification, mail.MagicLinkVerification: |
| 155 | user, terr = a.recoverVerify(r, tx, user) |
| 156 | case mail.EmailChangeVerification: |
| 157 | user, terr = a.emailChangeVerify(r, tx, params, user) |
| 158 | if user == nil && terr == nil { |
| 159 | // only one OTP is confirmed at this point, so we return early and ask the user to confirm the second OTP |
| 160 | rurl, terr = a.prepRedirectURL(singleConfirmationAccepted, params.RedirectTo, flowType) |
| 161 | if terr != nil { |
| 162 | return terr |
| 163 | } |
| 164 | return nil |
| 165 | } |
| 166 | default: |
| 167 | return apierrors.NewBadRequestError(apierrors.ErrorCodeValidationFailed, "Unsupported verification type") |
| 168 | } |
| 169 | |
| 170 | if terr != nil { |
| 171 | return terr |
| 172 | } |
| 173 | |
| 174 | if terr := user.UpdateAppMetaDataProviders(tx); terr != nil { |
| 175 | return terr |
| 176 | } |
| 177 |
no test coverage detected