Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nae-react-auth

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nae-react-auth - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/components/Auth/NaeAuthLoginPage.d.ts

10

dist/index.d.ts

@@ -1,6 +0,4 @@

/// <reference types="react" />
interface Props {
text: string;
}
export declare const ExampleComponent: ({ text }: Props) => JSX.Element;
export {};
import NaeAuthLoginPage from './components/Auth/NaeAuthLoginPage';
import NaeAuthRegisterPage from './components/Auth/NaeAuthRegisterPage';
import NaeApiAuth from './service/NaeApiAuth';
export { NaeAuthLoginPage, NaeAuthRegisterPage, NaeApiAuth };

222

dist/index.js

@@ -0,13 +1,221 @@

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var React__default = _interopDefault(React);
var reactBootstrap = require('react-bootstrap');
var reactRouterDom = require('react-router-dom');
var styles = {"test":"_3ybTi"};
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var ExampleComponent = function ExampleComponent(_ref) {
var text = _ref.text;
return React.createElement("div", {
className: styles.test
}, "Example Component: ", text);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var NaeApiAuthService = function NaeApiAuthService() {
var _this = this;
this.plainRequestOptions = function () {
return {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
};
this.doLogin = function (email, password) {
var requestOptions = _extends({}, _this.plainRequestOptions(), {
body: JSON.stringify({
email: email,
password: password
})
});
return fetch(_this.baseUrl + '/login', requestOptions).then(function (res) {
return res.json();
});
};
this.doRegister = function (email, password, passwordRepeat) {
var requestOptions = _extends({}, _this.plainRequestOptions(), {
body: JSON.stringify({
email: email,
password: password,
passwordRepeat: passwordRepeat
})
});
return fetch(_this.baseUrl + '/register', requestOptions).then(function (res) {
return res.json();
});
};
this.baseUrl = '/app/auth';
if (process.env.NODE_ENV === 'development') {
this.baseUrl = 'http://localhost:8000/app/auth';
}
};
exports.ExampleComponent = ExampleComponent;
var NaeApiAuth = new NaeApiAuthService();
function NaeAuthLoginPage() {
var history = reactRouterDom.useHistory();
var _useState = React.useState(''),
email = _useState[0],
setEmail = _useState[1];
var _useState2 = React.useState(''),
password = _useState2[0],
setPassword = _useState2[1];
var goToSignUp = function goToSignUp() {
history.push('/register');
};
var doLogin = function doLogin() {
NaeApiAuth.doLogin(email, password).then(function (res) {
if (res.isError) {
alert(res.error.description);
return;
}
window.localStorage.setItem('token', res.token);
history.push('/');
})["catch"](function (e) {
return alert(e.message);
});
};
return React__default.createElement("div", {
className: 'full-height v-center'
}, React__default.createElement(reactBootstrap.Container, {
className: 'mt-n20vh'
}, React__default.createElement(reactBootstrap.Row, null, React__default.createElement(reactBootstrap.Col, {
sm: 3
}), React__default.createElement(reactBootstrap.Col, null, React__default.createElement(reactBootstrap.Card, null, React__default.createElement(reactBootstrap.Card.Header, null, "Login form"), React__default.createElement(reactBootstrap.Card.Body, null, React__default.createElement(reactBootstrap.Form, null, React__default.createElement(reactBootstrap.Form.Group, null, React__default.createElement(reactBootstrap.Form.Label, null, "Username:"), React__default.createElement(reactBootstrap.Form.Control, {
value: email,
onChange: function onChange(e) {
return setEmail(e.target.value);
}
})), React__default.createElement(reactBootstrap.Form.Group, null, React__default.createElement(reactBootstrap.Form.Label, null, "Password:"), React__default.createElement(reactBootstrap.Form.Control, {
type: 'password',
value: password,
onChange: function onChange(e) {
return setPassword(e.target.value);
}
})))), React__default.createElement(reactBootstrap.Card.Footer, null, React__default.createElement(reactBootstrap.Row, null, React__default.createElement(reactBootstrap.Col, {
className: 'v-center'
}, React__default.createElement("p", null, "New member?", ' ', React__default.createElement("a", {
href: '/register',
onClick: function onClick(e) {
e.preventDefault();
goToSignUp();
}
}, "Sign up"))), React__default.createElement(reactBootstrap.Col, {
className: 'text-right'
}, React__default.createElement(reactBootstrap.Button, {
type: 'button',
variant: 'primary',
onClick: function onClick() {
return doLogin();
}
}, "Login")))))), React__default.createElement(reactBootstrap.Col, {
sm: 3
}))));
}
function NaeAuthRegisterPage() {
var history = reactRouterDom.useHistory();
var _useState = React.useState(''),
email = _useState[0],
setEmail = _useState[1];
var _useState2 = React.useState(''),
password = _useState2[0],
setPassword = _useState2[1];
var _useState3 = React.useState(''),
passwordRepeat = _useState3[0],
setPasswordRepeat = _useState3[1];
var goToLogin = function goToLogin() {
history.push('/login');
};
var doRegister = function doRegister() {
NaeApiAuth.doRegister(email, password, passwordRepeat).then(function (res) {
if (res.isError) {
alert(res.error.description);
return;
}
window.localStorage.setItem('token', res.token);
history.push('/');
})["catch"](function (e) {
return alert(e.message);
});
};
return React__default.createElement("div", {
className: 'full-height v-center'
}, React__default.createElement(reactBootstrap.Container, {
className: 'mt-n20vh'
}, React__default.createElement(reactBootstrap.Row, null, React__default.createElement(reactBootstrap.Col, {
sm: 3
}), React__default.createElement(reactBootstrap.Col, null, React__default.createElement(reactBootstrap.Card, null, React__default.createElement(reactBootstrap.Card.Header, null, "Sign up form"), React__default.createElement(reactBootstrap.Card.Body, null, React__default.createElement(reactBootstrap.Form, null, React__default.createElement(reactBootstrap.Form.Group, null, React__default.createElement(reactBootstrap.Form.Label, null, "E-mail:"), React__default.createElement(reactBootstrap.Form.Control, {
value: email,
onChange: function onChange(e) {
return setEmail(e.target.value);
}
})), React__default.createElement(reactBootstrap.Form.Group, null, React__default.createElement(reactBootstrap.Form.Label, null, "Password:"), React__default.createElement(reactBootstrap.Form.Control, {
type: 'password',
value: password,
onChange: function onChange(e) {
return setPassword(e.target.value);
}
})), React__default.createElement(reactBootstrap.Form.Group, null, React__default.createElement(reactBootstrap.Form.Label, null, "Repeat password:"), React__default.createElement(reactBootstrap.Form.Control, {
type: 'password',
value: passwordRepeat,
onChange: function onChange(e) {
return setPasswordRepeat(e.target.value);
}
})))), React__default.createElement(reactBootstrap.Card.Footer, null, React__default.createElement(reactBootstrap.Row, null, React__default.createElement(reactBootstrap.Col, {
className: 'v-center'
}, React__default.createElement("p", null, "Already have an account?", ' ', React__default.createElement("a", {
href: '/login',
onClick: function onClick(e) {
e.preventDefault();
goToLogin();
}
}, "Login"))), React__default.createElement(reactBootstrap.Col, {
className: 'text-right'
}, React__default.createElement(reactBootstrap.Button, {
type: 'button',
variant: 'primary',
onClick: function onClick() {
return doRegister();
}
}, "Sign up")))))), React__default.createElement(reactBootstrap.Col, {
sm: 3
}))));
}
exports.NaeApiAuth = NaeApiAuth;
exports.NaeAuthLoginPage = NaeAuthLoginPage;
exports.NaeAuthRegisterPage = NaeAuthRegisterPage;
//# sourceMappingURL=index.js.map

@@ -1,13 +0,216 @@

import { createElement } from 'react';
import React, { useState } from 'react';
import { Container, Row, Col, Card, Form, Button } from 'react-bootstrap';
import { useHistory } from 'react-router-dom';
var styles = {"test":"_3ybTi"};
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
var ExampleComponent = function ExampleComponent(_ref) {
var text = _ref.text;
return createElement("div", {
className: styles.test
}, "Example Component: ", text);
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var NaeApiAuthService = function NaeApiAuthService() {
var _this = this;
this.plainRequestOptions = function () {
return {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
};
this.doLogin = function (email, password) {
var requestOptions = _extends({}, _this.plainRequestOptions(), {
body: JSON.stringify({
email: email,
password: password
})
});
return fetch(_this.baseUrl + '/login', requestOptions).then(function (res) {
return res.json();
});
};
this.doRegister = function (email, password, passwordRepeat) {
var requestOptions = _extends({}, _this.plainRequestOptions(), {
body: JSON.stringify({
email: email,
password: password,
passwordRepeat: passwordRepeat
})
});
return fetch(_this.baseUrl + '/register', requestOptions).then(function (res) {
return res.json();
});
};
this.baseUrl = '/app/auth';
if (process.env.NODE_ENV === 'development') {
this.baseUrl = 'http://localhost:8000/app/auth';
}
};
export { ExampleComponent };
var NaeApiAuth = new NaeApiAuthService();
function NaeAuthLoginPage() {
var history = useHistory();
var _useState = useState(''),
email = _useState[0],
setEmail = _useState[1];
var _useState2 = useState(''),
password = _useState2[0],
setPassword = _useState2[1];
var goToSignUp = function goToSignUp() {
history.push('/register');
};
var doLogin = function doLogin() {
NaeApiAuth.doLogin(email, password).then(function (res) {
if (res.isError) {
alert(res.error.description);
return;
}
window.localStorage.setItem('token', res.token);
history.push('/');
})["catch"](function (e) {
return alert(e.message);
});
};
return React.createElement("div", {
className: 'full-height v-center'
}, React.createElement(Container, {
className: 'mt-n20vh'
}, React.createElement(Row, null, React.createElement(Col, {
sm: 3
}), React.createElement(Col, null, React.createElement(Card, null, React.createElement(Card.Header, null, "Login form"), React.createElement(Card.Body, null, React.createElement(Form, null, React.createElement(Form.Group, null, React.createElement(Form.Label, null, "Username:"), React.createElement(Form.Control, {
value: email,
onChange: function onChange(e) {
return setEmail(e.target.value);
}
})), React.createElement(Form.Group, null, React.createElement(Form.Label, null, "Password:"), React.createElement(Form.Control, {
type: 'password',
value: password,
onChange: function onChange(e) {
return setPassword(e.target.value);
}
})))), React.createElement(Card.Footer, null, React.createElement(Row, null, React.createElement(Col, {
className: 'v-center'
}, React.createElement("p", null, "New member?", ' ', React.createElement("a", {
href: '/register',
onClick: function onClick(e) {
e.preventDefault();
goToSignUp();
}
}, "Sign up"))), React.createElement(Col, {
className: 'text-right'
}, React.createElement(Button, {
type: 'button',
variant: 'primary',
onClick: function onClick() {
return doLogin();
}
}, "Login")))))), React.createElement(Col, {
sm: 3
}))));
}
function NaeAuthRegisterPage() {
var history = useHistory();
var _useState = useState(''),
email = _useState[0],
setEmail = _useState[1];
var _useState2 = useState(''),
password = _useState2[0],
setPassword = _useState2[1];
var _useState3 = useState(''),
passwordRepeat = _useState3[0],
setPasswordRepeat = _useState3[1];
var goToLogin = function goToLogin() {
history.push('/login');
};
var doRegister = function doRegister() {
NaeApiAuth.doRegister(email, password, passwordRepeat).then(function (res) {
if (res.isError) {
alert(res.error.description);
return;
}
window.localStorage.setItem('token', res.token);
history.push('/');
})["catch"](function (e) {
return alert(e.message);
});
};
return React.createElement("div", {
className: 'full-height v-center'
}, React.createElement(Container, {
className: 'mt-n20vh'
}, React.createElement(Row, null, React.createElement(Col, {
sm: 3
}), React.createElement(Col, null, React.createElement(Card, null, React.createElement(Card.Header, null, "Sign up form"), React.createElement(Card.Body, null, React.createElement(Form, null, React.createElement(Form.Group, null, React.createElement(Form.Label, null, "E-mail:"), React.createElement(Form.Control, {
value: email,
onChange: function onChange(e) {
return setEmail(e.target.value);
}
})), React.createElement(Form.Group, null, React.createElement(Form.Label, null, "Password:"), React.createElement(Form.Control, {
type: 'password',
value: password,
onChange: function onChange(e) {
return setPassword(e.target.value);
}
})), React.createElement(Form.Group, null, React.createElement(Form.Label, null, "Repeat password:"), React.createElement(Form.Control, {
type: 'password',
value: passwordRepeat,
onChange: function onChange(e) {
return setPasswordRepeat(e.target.value);
}
})))), React.createElement(Card.Footer, null, React.createElement(Row, null, React.createElement(Col, {
className: 'v-center'
}, React.createElement("p", null, "Already have an account?", ' ', React.createElement("a", {
href: '/login',
onClick: function onClick(e) {
e.preventDefault();
goToLogin();
}
}, "Login"))), React.createElement(Col, {
className: 'text-right'
}, React.createElement(Button, {
type: 'button',
variant: 'primary',
onClick: function onClick() {
return doRegister();
}
}, "Sign up")))))), React.createElement(Col, {
sm: 3
}))));
}
export { NaeApiAuth, NaeAuthLoginPage, NaeAuthRegisterPage };
//# sourceMappingURL=index.modern.js.map
{
"name": "nae-react-auth",
"version": "0.0.1",
"version": "0.0.2",
"description": "nae auth",

@@ -10,3 +10,3 @@ "author": "newageerp",

"module": "dist/index.modern.js",
"source": "src/index.tsx",
"source": "src/index.ts",
"engines": {

@@ -38,5 +38,5 @@ "node": ">=10"

"@types/react-dom": "^16.9.7",
"@types/react-router-dom": "^5.1.6",
"@typescript-eslint/eslint-plugin": "^2.26.0",
"@typescript-eslint/parser": "^2.26.0",
"microbundle-crl": "^0.13.10",
"babel-eslint": "^10.0.3",

@@ -55,2 +55,3 @@ "cross-env": "^7.0.2",

"gh-pages": "^2.2.0",
"microbundle-crl": "^0.13.10",
"npm-run-all": "^4.1.5",

@@ -65,3 +66,7 @@ "prettier": "^2.0.4",

"dist"
]
],
"dependencies": {
"react-bootstrap": "^1.4.0",
"react-router-dom": "^5.2.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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