New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

j-tockauth

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

j-tockauth

javascript connector for DeviseTokenAuth for Ruby on Rails

  • 1.2.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

J-tockauth

A connector for javascript application frontend to Ruby on Rails with Devise Token Auth gem backend

Usage

import JtockAuth from "j-tockauth";

const auth = new JtockAuth({
  host: "http://127.0.0.1:3000",
  prefixUrl: "/api/v1",
  debug: false
});

export default auth;

SignUp

import auth from "./auth";

auth
  .signUp(
    {
      email: "john-doe@gmail.com",
      password: "myP@ssw0ord!",
      avatarUrl: "www.image.com/picture.jpg"
    },
    "www.url-after-confirmation.com"
  )
  .then(userDatas => {
    console.log(userDatas);
  })
  .catch(error => {
    console.log(error);
  });

SignIn

import auth from "./auth";

auth
  .signIn("john-doe@gmail.com", "myP@ssw0ord!")
  .then(userDatas => {
    console.log(userDatas);
  })
  .catch(error => {
    console.log(error);
  });

SignOut (need an active session)

import auth from "./auth";

auth
  .signOut()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });

Delete resource (need an active session)

import auth from "./auth";

auth
  .deleteResource()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });

Change password (need an active session)

import auth from "./auth";

auth
  .changePassword("myP@ssw0ord!", "newp@SSw0rd", "newp@SSw0rd")
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });
import auth from "./auth";

auth
  .resetPassword("john-doe@gmail.com", "www.reset-password-link.com")
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });

Update password after email reset

import auth from "./auth";

auth
  .updatePasswordByToken(
    "jd97-MDsj763fsGSU",
    "www.url-after-reset-password-success.com"
  )
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.log(error);
  });

Protected routes

import auth from "./auth";

auth
  .authenticateRoute("/posts", {
    method: "POST",
    // data can be an json object or a FormData
    data: { title: "My post title", body: "My post body", user_id: 1 }
  })
  .then(postsResponse => {
    console.log(postsResponse);
  })
  .catch(error => {
    console.log(error);
  });

Keywords

FAQs

Package last updated on 04 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc