EnterCode Signup working
- After fetching join code in EnterCode(), it sets networkId attribute on "signup-" (Signup.js)
- Signup.js then includes the attribute in the call body
- Modified all calls to /signout, /profile, /login, /signup to be prefixed by '/auth'
- Added '/auth' to vite config file
- Modified final "else if" statement in .attr in quill.js to return `this.getAttribute(arg1)` instead of `this.getAttribute("")`
This commit is contained in:
@@ -82,13 +82,15 @@ class EnterCode extends Shadow {
|
|||||||
console.log("submit")
|
console.log("submit")
|
||||||
const res = await fetch(`${util.HOST}/auth/joincode`, {
|
const res = await fetch(`${util.HOST}/auth/joincode`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json', "Accept": "application/json" },
|
||||||
body: JSON.stringify({ code: this.$("input").value })
|
body: JSON.stringify({ code: this.$("input").value })
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
console.log("got join code succ")
|
console.log("got join code succ")
|
||||||
this.attr("codeaccepted", "true")
|
this.attr("codeaccepted", "true")
|
||||||
|
let { networkId } = await res.json()
|
||||||
|
$("signup-").attr("networkid", networkId)
|
||||||
} else {
|
} else {
|
||||||
const { error } = await res.json();
|
const { error } = await res.json();
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class Login extends Shadow {
|
|||||||
this.$("p").attr({ errorType: "" });
|
this.$("p").attr({ errorType: "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await fetch(`${util.HOST}/login`, {
|
const res = await fetch(`${util.HOST}/auth/login`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json", "X-Client": "mobile" },
|
headers: { "Content-Type": "application/json", "X-Client": "mobile" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|||||||
@@ -112,10 +112,12 @@ class Signup extends Shadow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async requestSignup(data) {
|
async requestSignup(data) {
|
||||||
const res = await fetch(`${util.HOST}/signup`, {
|
const networkId = this.attr("networkid");
|
||||||
|
const res = await fetch(`${util.HOST}/auth/signup`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json", "X-Client": "mobile" },
|
headers: { "Content-Type": "application/json", "X-Client": "mobile" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
networkId: networkId,
|
||||||
firstName: data.get("firstName"),
|
firstName: data.get("firstName"),
|
||||||
lastName: data.get("lastName"),
|
lastName: data.get("lastName"),
|
||||||
email: data.get("email"),
|
email: data.get("email"),
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ let Global = class {
|
|||||||
|
|
||||||
async getProfile() {
|
async getProfile() {
|
||||||
try {
|
try {
|
||||||
const res = await util.authFetch(`${util.HOST}/profile`, {
|
const res = await util.authFetch(`${util.HOST}/auth/profile`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -150,7 +150,7 @@ let Global = class {
|
|||||||
|
|
||||||
async onLogout() {
|
async onLogout() {
|
||||||
await util.removeAuthToken()
|
await util.removeAuthToken()
|
||||||
await fetch(`${util.HOST}/signout`, {
|
await fetch(`${util.HOST}/auth/signout`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
credentials: "include"
|
credentials: "include"
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1261,7 +1261,7 @@ HTMLElement.prototype.attr = function(arg1, arg2) {
|
|||||||
this.setAttribute(arg1, arg2)
|
this.setAttribute(arg1, arg2)
|
||||||
return this
|
return this
|
||||||
} else if(typeof arg1 === "string") {
|
} else if(typeof arg1 === "string") {
|
||||||
return this.getAttribute("")
|
return this.getAttribute(arg1)
|
||||||
} else {
|
} else {
|
||||||
throw new TypeError("wrong parameter for attr(): ", arg1);
|
throw new TypeError("wrong parameter for attr(): ", arg1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,6 @@ export default defineConfig({
|
|||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
ws: true
|
ws: true
|
||||||
},
|
},
|
||||||
"/login": {
|
|
||||||
target: "http://localhost:10002",
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
"/signup": {
|
|
||||||
target: "http://localhost:10002",
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
"/signout": {
|
|
||||||
target: "http://localhost:10002",
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
"/profile": {
|
|
||||||
target: "http://localhost:10002",
|
|
||||||
changeOrigin: true
|
|
||||||
},
|
|
||||||
"/profile/upload-image": {
|
"/profile/upload-image": {
|
||||||
target: "http://localhost:10002",
|
target: "http://localhost:10002",
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
@@ -47,6 +31,10 @@ export default defineConfig({
|
|||||||
"/apps": {
|
"/apps": {
|
||||||
target: "http://localhost:10002",
|
target: "http://localhost:10002",
|
||||||
changeOrigin: true
|
changeOrigin: true
|
||||||
|
},
|
||||||
|
"/auth": {
|
||||||
|
target: "http://localhost:10002",
|
||||||
|
changeOrigin: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
host: true,
|
host: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user