当前位置: 首页>>代码示例>>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;未经允许,请勿转载。