Fakultas Ilmu Komputer UI

Commit 047aa413 authored by Jonathan's avatar Jonathan
Browse files

Merge branch 'jonathan' into 'master'

Jonathan

See merge request !31
parents 8977fd2b 3f12e3fb
......@@ -74,7 +74,7 @@ export default function Profile(props) {
<b>Your threads</b>
)}
{username != profileUsername && (
<b>{user.username}s threads</b>
<b>{user.username}'s threads</b>
)}
</h3>
......
......@@ -4,13 +4,14 @@ import { useInput } from '../../helpers/hooks/input-hook';
import '../../styles/profile/UpdateProfileForm.css';
import authHeader from '../../helpers/services/authHeader.service';
import { API_URL } from '../../config/keys';
import AuthService from '../../helpers/services/auth.service';
export default function FormCreateThread(props) {
const {
value: username,
bind: bindUsername,
reset: resetUsername,
} = useInput('');
} = useInput(AuthService.getCurrentUsername());
const [message, setMessage] = useState('');
const back = () => {
......
......@@ -2,31 +2,8 @@ import axios from 'axios';
import { API_URL } from '../../config/keys';
class AuthService {
async login(email, password) {
const response = await axios.post(`${API_URL}/users/signin`, {
email,
password,
});
if (response?.data?.token)
localStorage.setItem('user', JSON.stringify(response.data));
return response;
}
logout() {
localStorage.removeItem('user');
localStorage.removeItem('callback');
}
async register(username, email, password) {
const response = await axios.post(`${API_URL}/users/signup`, {
user: {
username,
email,
password,
},
});
await this.login(email, password);
return response;
}
getCurrentUser() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment