Skip to content

Academics-and-Career-Council/kratos-verify-session

Repository files navigation

kratos-verify-session

Propreity package to check Ory Kratos session and handle redirects accordingly

NPM JavaScript Style Guide

Install

npm install --save kratos-verify-session

Usage

import React, { Component } from 'react'

import Verify from 'kratos-verify-session'
import 'kratos-verify-session/dist/index.css'

class Example extends Component {
  render() {
    return <Verfiy 
      loginUrl: 'url to login page'
      basePath: 'basePath of your main application' //eg http://localhost:3000
      path: 'on path that you want to go' //eg dashboard
      historyPush: 'funtion to push the new route in history'
      setSessionState: 'funtion to update session state'
      xenon: 'pass a xenon reference aftrer importing in your application'
      ory: 'locally defined ory instance in your application'
    />
  }
}

session state

interface sessionState {
  active: boolean
  logoutUrl: string
  user: UserCrediantials //type obtained from @anciitk/xenon
  session: Session //type obtained from @ory/kratos-client
}

historyPush

for react

const app = ({history}) => {
  // this function was provided by react router
  history.push(/something)
}

for next

import {useRouter} from 'next/router'

const app = () => {
  const router = useRouter();
  historyPush = router.push;
}

License

MIT © Mshivam2409

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published