mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-22 22:47:02 +00:00
Fixes availablity of user for Home component
This commit is contained in:
parent
166e024bb3
commit
88612e9cff
@ -10,13 +10,28 @@ import userManager, { loadUserFromStorage } from './services/userService';
|
||||
import AuthProvider from './utils/authProvider';
|
||||
import PrivateRoute from './utils/protectedRoute';
|
||||
import './index.css';
|
||||
import {storeUser} from './actions/authActions'
|
||||
|
||||
function App() {
|
||||
useEffect(() => {
|
||||
// Commented out not to check the localStorage for the user's existence ** Temporary **
|
||||
|
||||
// fetch current user from cookies
|
||||
loadUserFromStorage(store);
|
||||
// loadUserFromStorage(store);
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
// Should be removed ** Temporary **
|
||||
const logUserIn = () => {
|
||||
const user = {profile: {given_name: 'John Doe'}}
|
||||
console.log(`User logged in!`)
|
||||
store.dispatch(storeUser(user))
|
||||
}
|
||||
|
||||
// ** Temporary **
|
||||
logUserIn()
|
||||
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<AuthProvider userManager={userManager} store={store}>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
const Button = () => (
|
||||
<button className="bg-blue-custom border-0 font-inter font-semibold rounded text-xl m-0">
|
||||
const Button = ({onClickEvent}) => (
|
||||
<button onClick={onClickEvent} className="bg-blue-custom border-0 font-inter font-semibold rounded text-xl m-0">
|
||||
Login
|
||||
</button>
|
||||
);
|
||||
|
||||
@ -1,7 +1,20 @@
|
||||
import React from 'react';
|
||||
import Button from './Button';
|
||||
import {storeUser} from '../../actions/authActions'
|
||||
import store from '../../store'
|
||||
import userManager from '../../services/userService'
|
||||
|
||||
const LoginWindow = () => {
|
||||
|
||||
|
||||
const onUserLogin = () => {
|
||||
const user = {profile: {given_name: 'John Doe'}}
|
||||
console.log(`User logged in!`)
|
||||
store.dispatch(storeUser(user))
|
||||
// Looks like we don't have this function even tho it's in the library installed
|
||||
// userManager.storeUser(user).then(()=> console.log('yay')).catch(()=> console.log('nope'))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="xl:w-1/3 lg:w-5/12 md:w-2/4 sm:w-9/12 w-11/12 flex flex-col justify-center shadow md:px-32 sm:px-28 md:py-40 sm:py-36 px-20 py-16">
|
||||
<h1 className="font-playfair text-black-custom text-6xl mb-12">
|
||||
@ -10,7 +23,7 @@ const LoginWindow = () => {
|
||||
<p className="text-black-custom font-light text-3xl mb-20">
|
||||
Login to your account to view your dashboard and register a new vehicle.
|
||||
</p>
|
||||
<Button />
|
||||
<Button onClickEvent={onUserLogin} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user