-
Notifications
You must be signed in to change notification settings - Fork 3
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
Vahdet Parlak
committed
Jul 16, 2024
1 parent
4dc012b
commit c081935
Showing
15 changed files
with
136 additions
and
104 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { navigateTo } from "../../utils/navTo.js"; | ||
import { insertIntoElement, toggleHidden } from "../../utils/utils.js"; | ||
|
||
const url = "http://127.0.0.1:8000/user/username"; | ||
|
||
export async function fetchConflictusername() { | ||
const form = document.getElementById("uname-code"); | ||
|
||
const urlParams = new URLSearchParams(window.location.search); | ||
const access_token = urlParams.get("access_token"); | ||
const refresh_token = urlParams.get("refresh_token"); | ||
|
||
form.addEventListener("submit", async (e) => { | ||
e.preventDefault(); | ||
const username = document.getElementById("username").value; | ||
const fields_warning = document.getElementById('fields-warning'); | ||
if (!username) { | ||
insertIntoElement('fields-warning', "Username shouldn't be empty"); | ||
return; | ||
} | ||
toggleHidden('uname-code'); | ||
toggleHidden('login-spinner'); | ||
|
||
try { | ||
const response = await fetch(url, { | ||
method: "PATCH", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Authorization": `Bearer ${access_token}`, | ||
}, | ||
body: JSON.stringify({ | ||
username: username, | ||
}) | ||
}); | ||
|
||
if (!response.ok) { | ||
const errorData = await response.json(); | ||
throw errorData; | ||
} | ||
localStorage.setItem("access_token", access_token); | ||
localStorage.setItem("refresh_token", refresh_token); | ||
navigateTo("/"); | ||
} catch (err) { | ||
console.log("123123123123123", err); | ||
if (err.error) { | ||
insertIntoElement('fields-warning', "Error: " + err.error); | ||
} else if (err.username) { | ||
insertIntoElement('fields-warning', "Username error: " + err.username); | ||
} | ||
toggleHidden('uname-code'); | ||
toggleHidden('login-spinner'); | ||
} | ||
}); | ||
} |
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
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
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 |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
} | ||
</style> | ||
<canvas id="canvas-pong" width="960" height="480"></canvas> | ||
|
||
|
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
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
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
Oops, something went wrong.