nae-react-auth
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -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 }; |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45568
13
415
3
30
3
5
+ Addedreact-bootstrap@^1.4.0
+ Addedreact-router-dom@^5.2.0
+ Added@babel/runtime@7.26.0(transitive)
+ Added@popperjs/core@2.11.8(transitive)
+ Added@restart/context@2.1.4(transitive)
+ Added@restart/hooks@0.4.16(transitive)
+ Added@types/invariant@2.2.37(transitive)
+ Added@types/prop-types@15.7.14(transitive)
+ Added@types/react@19.0.2(transitive)
+ Added@types/react-transition-group@4.4.12(transitive)
+ Added@types/warning@3.0.3(transitive)
+ Addedclassnames@2.5.1(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddom-helpers@5.2.1(transitive)
+ Addedhistory@4.10.1(transitive)
+ Addedhoist-non-react-statics@3.3.2(transitive)
+ Addedinvariant@2.2.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedpath-to-regexp@1.9.0(transitive)
+ Addedprop-types-extra@1.1.1(transitive)
+ Addedreact@19.0.0(transitive)
+ Addedreact-bootstrap@1.6.8(transitive)
+ Addedreact-dom@19.0.0(transitive)
+ Addedreact-lifecycles-compat@3.0.4(transitive)
+ Addedreact-overlays@5.2.1(transitive)
+ Addedreact-router@5.3.4(transitive)
+ Addedreact-router-dom@5.3.4(transitive)
+ Addedreact-transition-group@4.4.5(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedresolve-pathname@3.0.0(transitive)
+ Addedscheduler@0.25.0(transitive)
+ Addedtiny-invariant@1.3.3(transitive)
+ Addedtiny-warning@1.0.3(transitive)
+ Addeduncontrollable@7.2.1(transitive)
+ Addedvalue-equal@1.0.1(transitive)
+ Addedwarning@4.0.3(transitive)