-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
922 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@import 'assets/style/variables.scss'; | ||
@import "~bootstrap/scss/bootstrap"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@import 'assets/style/variables.scss'; | ||
@import "~bootstrap/scss/bootstrap"; | ||
@import 'assets/style/header.scss'; | ||
@import 'assets/style/sign-in.scss'; | ||
|
||
html { | ||
height: 100%; | ||
} | ||
|
||
body { | ||
font-size: 1em; | ||
font-family: Verdana, Helvetica, sans-serif; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.zfgc-header{ | ||
border-bottom: .2em solid black; | ||
padding: 1em; | ||
|
||
.user-heading{ | ||
font-weight: bold; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.sign-in-form{ | ||
|
||
form{ | ||
background-color: $msecondary; | ||
padding: 2em; | ||
border: $border-stroke solid; | ||
border-radius: $border-radius; | ||
margin-top: 2em; | ||
box-shadow: 0.3em 1em 1em black; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$mprimary: #204378; | ||
$msecondary: #25334E; | ||
$msecondary2: #132241; | ||
|
||
$onPrimary: #d5dffb; | ||
$onPrimary2: #black; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@import './themes/midnight-colors.scss'; | ||
|
||
$border-radius: .5em; | ||
$border-stroke: .2em; | ||
|
||
.theme-midnight { | ||
background-color: $mprimary; | ||
color: $onPrimary; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import Form from 'react-bootstrap/Form'; | ||
import Button from 'react-bootstrap/Button'; | ||
import UserEndpoints from './../../utilities/axios/users.endpoints.js'; | ||
import AuthStore from './../../utilities/common/AuthStore.common.js'; | ||
|
||
function SignIn() { | ||
|
||
/*function handleAuthenticate(event){ | ||
event.preventDefault(); | ||
}*/ | ||
let signInForm = { | ||
"username": null, | ||
"password": null | ||
}; | ||
|
||
const handleSubmit = (event) => { | ||
event.preventDefault(); | ||
signInForm.username = event.target[0].value; | ||
signInForm.password = event.target[1].value; | ||
let auth = UserEndpoints.getClausiusLogin(signInForm); | ||
auth.then(data => { | ||
AuthStore.getInstance().setJwtToken(data.data); | ||
|
||
let user = UserEndpoints.getLoggedInUser(); | ||
}); | ||
|
||
|
||
}; | ||
|
||
return ( | ||
<div className="sign-in-form justify-content-center d-flex"> | ||
<Form className="col-6" onSubmit={handleSubmit}> | ||
<Form.Group> | ||
<Form.Label>Username</Form.Label> | ||
<Form.Control type="input" name="username"></Form.Control> | ||
</Form.Group> | ||
|
||
<Form.Group> | ||
<Form.Label>Password</Form.Label> | ||
<Form.Control type="password" name="password"></Form.Control> | ||
</Form.Group> | ||
|
||
<Form.Group> | ||
<Button type="submit">Sign in</Button> | ||
</Form.Group> | ||
</Form> | ||
</div> | ||
); | ||
|
||
} | ||
|
||
|
||
|
||
export default SignIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import {Link} from "react-router-dom"; | ||
|
||
class ZfgcHeader extends React.Component { | ||
render () { | ||
return ( | ||
<div className="zfgc-header"> | ||
<div className="user-heading"> | ||
Welcome, friend!<br/> | ||
<Link to='/signin'>Sign in</Link> or Register | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default ZfgcHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import './components/sign-in/sign-in.component.js'; | ||
|
||
class LoginRoute extends React.Component { | ||
render (){ | ||
return ( | ||
<div> | ||
<SignIn></SignIn> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
|
||
export default LoginRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import ZfgcApi from './zfgc-api.endpoints'; | ||
import AuthStore from './../common/AuthStore.common.js'; | ||
|
||
class UserEndpoints extends React.Component { | ||
|
||
static async getClausiusLogin(body){ | ||
return ZfgcApi.post('users/auth/login', body); | ||
} | ||
|
||
static async getLoggedInUser(){ | ||
let accessToken = AuthStore.getInstance().getJwtToken(); | ||
ZfgcApi.get('users/loggedInUser', {headers : { | ||
'Authorization' : 'bearer ' + accessToken.access_token | ||
}}); | ||
} | ||
|
||
} | ||
|
||
export default UserEndpoints; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import axios from 'axios'; | ||
|
||
export default axios.create({ | ||
baseURL: "http://localhost:8080/forum/" | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
|
||
export default class AuthStore { | ||
static myInstance = null; | ||
|
||
jwtToken = null; | ||
|
||
static getInstance() { | ||
if(AuthStore.myInstance == null){ | ||
AuthStore.myInstance = new AuthStore(); | ||
} | ||
|
||
return this.myInstance; | ||
} | ||
|
||
getJwtToken (){ return this.jwtToken}; | ||
setJwtToken (jwt) { this.jwtToken = jwt; console.log("stored JWT")}; | ||
} |
Oops, something went wrong.