Adds POC Login Form in React

This commit is contained in:
Michael 2020-03-28 13:51:31 -05:00
parent ac3cbcb613
commit a7f54991c1
4 changed files with 58 additions and 8 deletions

View File

@ -116,10 +116,14 @@ ACCOUNT_EMAIL_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_AUTHENTICATION_METHOD = 'username'
ACCOUNT_EMAIL_VERIFICATION = 'optional' ACCOUNT_EMAIL_VERIFICATION = 'optional'
REST_USE_JWT = True
JWT_AUTH_COOKIE = 'auth'
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ( 'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.TokenAuthentication',
'dj_rest_auth.utils.JWTCookieAuthentication'
), ),
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
} }
@ -130,4 +134,5 @@ SWAGGER_SETTINGS = {
} }
CORS_ORIGIN_ALLOW_ALL = True # For demo purposes only. Use a white list in the real world. # For demo purposes only. Use a white list in the real world.
CORS_ORIGIN_ALLOW_ALL = True

View File

@ -1,5 +1,6 @@
.App { .App {
text-align: center; text-align: center;
width: 100%;
} }
.App-logo { .App-logo {
@ -22,6 +23,7 @@
justify-content: center; justify-content: center;
font-size: calc(10px + 2vmin); font-size: calc(10px + 2vmin);
color: white; color: white;
width: 100%;
} }
.App-link { .App-link {

View File

@ -18,21 +18,28 @@ function App() {
body: JSON.stringify({username, password}) body: JSON.stringify({username, password})
}).then(resp => resp.json()).then(data => { }).then(resp => resp.json()).then(data => {
changeResponse(data) changeResponse(data)
}) }).catch(error => console.log('error ->', error))
} }
return ( return (
<div className="App"> <div className="App">
<header className="App-header"> <header className="App-header">
<p> <h1>
Login Login
</p> </h1>
<p> <div className={'help-text'}>
Inspect the network requests in your browser to view headers returned by dj-rest-auth.
</div>
<div>
{resp && {resp &&
<span>Response: {JSON.stringify(resp)}</span> <div className={'response'}>
<code>
{JSON.stringify(resp)}
</code>
</div>
} }
</p> </div>
<div>
<form onSubmit={onSubmit}> <form onSubmit={onSubmit}>
<div> <div>
<input <input
@ -50,6 +57,7 @@ function App() {
</div> </div>
<button type={'submit'}>Submit</button> <button type={'submit'}>Submit</button>
</form> </form>
</div>
</header> </header>
</div> </div>
); );

View File

@ -1,13 +1,48 @@
body { body {
margin: 0; margin: 0;
width: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif; sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
display: flex;
flex-direction: column;
}
body div {
flex-direction: row;
text-align: center;
display: flex;
justify-content: center;
}
ul {
width: 240px;
font-size: 11px;
} }
code { code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace; monospace;
word-break: break-all;
height: 200px;
color: #0f0f0f;
}
.response {
margin: 20px;
background-color: #eee;
width: 80%;
height: 200px;
overflow: scroll;
}
.help-text {
font-size: 11px;
margin: 20px;
}
form > div {
margin: 20px;
} }