Options
All
  • Public
  • Public/Protected
  • All
Menu

Module routes/github

Index

Variables

states: {} = {}

Type declaration

  • [key: string]: string

Functions

  • checkState(state: string): string | false
  • Checks if a state exists, then removes that state from the set of valid states.

    Parameters

    • state: string

      The state to check.

    Returns string | false

    True if the state is valid, otherwise false.

  • genState(redirect: string): string
  • Generates a new state for GitHub, then adds it to the current states. This state is a a string of 64 cryptographically random bytes.

    Parameters

    • redirect: string

    Returns string

    The new state.

  • getHome(): string
  • Gets the home URL for the github callback.

    Returns string

    The home URL.

  • getRouter(): express.Router
  • ghExchangeAccessToken(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>): Promise<void>
  • Step two of the GitHub OAuth process: exchanging the temporary code for an access token. This function first asks an access token, then checks if a a user exists in our system and if not, creates one.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>>

    Returns Promise<void>

  • ghIdentity(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, resp: Response<any, Record<string, any>>): Promise<void>
  • Step one of the GitHub OAuth process: getting the identity of the user. This calls GitHub's login, then asks Github to redirect the user to /github/challenge on our server. This function only generates a new state, makes it valid and then redirects.

    Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • resp: Response<any, Record<string, any>>

    Returns Promise<void>

  • ghSignupOrLogin(login: GHLogin): Promise<Responses.GithubLogin>
  • Callback for the actual signup and/or login. Uses the provided GitHub data to access our underlying database. If the user doesn't exist, their account is created. If the user exists, we check if we need to update their name and/or GitHub handle.

    Parameters

    • login: GHLogin

    Returns Promise<Responses.GithubLogin>

  • githubNameChange(login: GHLogin, person: { github: null | string; login_user: null | { account_status: account_status_enum; is_admin: boolean; is_coach: boolean; login_user_id: number; password: null | string }; name: string; person_id: number }): boolean
  • Checks if we need to update a GitHub user's name and/or handle.

    Parameters

    • login: GHLogin
    • person: { github: null | string; login_user: null | { account_status: account_status_enum; is_admin: boolean; is_coach: boolean; login_user_id: number; password: null | string }; name: string; person_id: number }
      • github: null | string
      • login_user: null | { account_status: account_status_enum; is_admin: boolean; is_coach: boolean; login_user_id: number; password: null | string }
      • name: string
      • person_id: number

    Returns boolean

  • parseGHLogin(data: Anything): Promise<Requests.GHLogin>
  • Checks if all required fields are available. We need (at least) a login, name and id in the request.

    Parameters

    • data: Anything

    Returns Promise<Requests.GHLogin>

Generated using TypeDoc