當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript oAuthHelper.OAuthHelper類代碼示例

本文整理匯總了TypeScript中idam/oAuthHelper.OAuthHelper的典型用法代碼示例。如果您正苦於以下問題:TypeScript OAuthHelper類的具體用法?TypeScript OAuthHelper怎麽用?TypeScript OAuthHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了OAuthHelper類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Cookies

    ErrorHandling.apply(async (req: express.Request,
                               res: express.Response,
                               next: express.NextFunction): Promise<void> => {
      const cookies = new Cookies(req, res)
      let user

      try {
        const authenticationToken = await getAuthToken(req)
        if (authenticationToken) {
          user = await IdamClient.retrieveUserFor(authenticationToken)
          res.locals.isLoggedIn = true
          res.locals.user = user
          setAuthCookie(cookies, authenticationToken)
        }
      } catch (err) {
        return loginErrorHandler(req, res, cookies, next, err)
      }

      if (res.locals.isLoggedIn) {
        if (isDefendantFirstContactPinLogin(req)) {
          // re-set state cookie as it was cleared above, we need it in this case
          cookies.set(stateCookieName, req.query.state)
          return res.redirect(FirstContactPaths.claimSummaryPage.uri)
        } else {
          await claimStoreClient.linkDefendant(user)
          res.redirect(await retrieveRedirectForLandingPage(req, res))
        }
      } else {
        if (res.locals.code) {
          trackCustomEvent('Authentication token undefined (jwt defined)',
            { requestValue: req.query.state })
        }
        res.redirect(OAuthHelper.forLogin(req, res))
      }
    }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:35,代碼來源:receiver.ts

示例2: getOAuthAccessToken

async function getOAuthAccessToken (req: express.Request, receiver: RoutablePath): Promise<string> {
  if (req.query.state !== OAuthHelper.getStateCookie(req)) {
    trackCustomEvent('State cookie mismatch (citizen)',
      {
        requestValue: req.query.state,
        cookieValue: OAuthHelper.getStateCookie(req)
      })
  }
  const authToken: AuthToken = await IdamClient.exchangeCode(
    req.query.code,
    buildURL(req, receiver.uri)
  )
  if (authToken) {
    return authToken.accessToken
  }
  return Promise.reject()
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:17,代碼來源:receiver.ts

示例3: loginErrorHandler

function loginErrorHandler (req: express.Request,
                            res: express.Response,
                            cookies: Cookies,
                            next: express.NextFunction,
                            err: Error,
                            receiver: RoutablePath = AppPaths.receiver) {
  if (hasTokenExpired(err)) {
    cookies.set(sessionCookie)
    logger.debug(`Protected path - expired auth token - access to ${req.path} rejected`)
    return res.redirect(OAuthHelper.forLogin(req, res, receiver))
  }
  cookies.set(stateCookieName, '')
  return next(err)
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:14,代碼來源:receiver.ts

示例4: renderView

    ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
      const form: Form<ClaimReference> = req.body

      if (form.hasErrors()) {
        renderView(form, res)
      } else {
        if (isCCBCCaseReference(form.model.reference)) {
          return res.redirect(mcolUrl)
        }

        const linked: boolean = await claimStoreClient.isClaimLinked(form.model.reference)

        if (linked) {
          return res.redirect(AppPaths.homePage.uri)
        }
        res.redirect(OAuthHelper.forPin(req, res, form.model.reference.toUpperCase()))
      }
    }))
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:18,代碼來源:claim-reference.ts

示例5: accessDeniedCallback

 function accessDeniedCallback (req: express.Request, res: express.Response): void {
   res.redirect(OAuthHelper.forLogin(req, res))
 }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:3,代碼來源:index.ts

示例6: receiverPath

function receiverPath (req: express.Request, res: express.Response): string {
  return `${OAuthHelper.forUplift(req, res)}&jwt=${JwtExtractor.extract(req)}`
}
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:3,代碼來源:claim-summary.ts

示例7: getClaimRef

 private static getClaimRef (req: express.Request): string {
   return OAuthHelper.getStateCookie(req)
 }
開發者ID:hmcts,項目名稱:cmc-citizen-frontend,代碼行數:3,代碼來源:claimReferenceMatchesGuard.ts


注:本文中的idam/oAuthHelper.OAuthHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。