This file contains hidden or 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
import { combineReducers } from "redux"; | |
import auth from "./auth"; | |
import message from "./message"; | |
export default combineReducers({ | |
auth, | |
message, | |
}); |
This file contains hidden or 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
import { | |
REGISTER_SUCCESS, | |
REGISTER_FAIL, | |
LOGIN_SUCCESS, | |
LOGIN_FAIL, | |
LOGOUT, | |
} from "../actions/types"; | |
const user = JSON.parse(localStorage.getItem("user")); |
This file contains hidden or 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
import { SET_MESSAGE, CLEAR_MESSAGE } from "../actions/types"; | |
const initialState = {}; | |
export default function (state = initialState, action) { | |
const { type, payload } = action; | |
switch (type) { | |
case SET_MESSAGE: | |
return { message: payload }; |
This file contains hidden or 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
import { | |
REGISTER_SUCCESS, | |
REGISTER_FAIL, | |
LOGIN_SUCCESS, | |
LOGIN_FAIL, | |
LOGOUT, | |
SET_MESSAGE, | |
} from "./types"; | |
import AuthService from "../services/auth.service"; |
This file contains hidden or 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
import { SET_MESSAGE, CLEAR_MESSAGE } from "./types"; | |
export const setMessage = (message) => ({ | |
type: SET_MESSAGE, | |
payload: message, | |
}); | |
export const clearMessage = () => ({ | |
type: CLEAR_MESSAGE, | |
}); |
This file contains hidden or 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
export const REGISTER_SUCCESS = "REGISTER_SUCCESS"; | |
export const REGISTER_FAIL = "REGISTER_FAIL"; | |
export const LOGIN_SUCCESS = "LOGIN_SUCCESS"; | |
export const LOGIN_FAIL = "LOGIN_FAIL"; | |
export const LOGOUT = "LOGOUT"; | |
export const SET_MESSAGE = "SET_MESSAGE"; | |
export const CLEAR_MESSAGE = "CLEAR_MESSAGE"; |
This file contains hidden or 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
import axios from "axios"; | |
// For Lumen 7 back-end | |
const API_URL = "http://localhost:8000/api/test/"; | |
// for Node.js Express back-end | |
// const API_URL = "http://localhost:9090/api/test/"; | |
const getPublicContent = () => { | |
return axios.get(API_URL + "all"); | |
}; |
This file contains hidden or 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
export default function authHeader() { | |
const user = JSON.parse(localStorage.getItem("user")); | |
if (user && user.accessToken) { | |
// For Lumen 7 back-end | |
return { Authorization: "Bearer " + user.accessToken }; | |
// for Node.js Express back-end | |
// return { "x-access-token": user.accessToken }; | |
} else { |
This file contains hidden or 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
import axios from "axios"; | |
// For Lumen 7 back-end | |
const API_URL = "http://localhost:8000/api/auth/"; | |
// for Node.js Express back-end | |
// const API_URL = "http://localhost:9090/api/auth/"; | |
const register = (username, email, password) => { | |
return axios.post(API_URL + "register", { | |
username, |
This file contains hidden or 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
import { NgModule } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { RegisterComponent } from './register/register.component'; | |
import { LoginComponent } from './login/login.component'; | |
import { ProfileComponent } from './profile/profile.component'; | |
import { HomeComponent } from './home/home.component'; | |
const routes: Routes = [ | |
{ path: 'home', component: HomeComponent }, |