replace localhost + checkLoggedIn + fix register/login links
This commit is contained in:
		
							parent
							
								
									00aac119f1
								
							
						
					
					
						commit
						a3cd614c61
					
				
					 4 changed files with 29 additions and 17 deletions
				
			
		| 
						 | 
					@ -4,12 +4,15 @@
 | 
				
			||||||
  import {
 | 
					  import {
 | 
				
			||||||
    ID,
 | 
					    ID,
 | 
				
			||||||
    account,
 | 
					    account,
 | 
				
			||||||
 | 
					    checkloggedin,
 | 
				
			||||||
    database,
 | 
					    database,
 | 
				
			||||||
    loggedInUser,
 | 
					    loggedInUser,
 | 
				
			||||||
    teams,
 | 
					    teams,
 | 
				
			||||||
  } from "../../lib/appwrite";
 | 
					  } from "../../lib/appwrite";
 | 
				
			||||||
  import { navigate } from "svelte-navigator/src/history";
 | 
					  import { navigate } from "svelte-navigator/src/history";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  checkloggedin();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let listname = "";
 | 
					  let listname = "";
 | 
				
			||||||
  let requireLoggedIn = false;
 | 
					  let requireLoggedIn = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,22 +30,24 @@
 | 
				
			||||||
          let permissions = [
 | 
					          let permissions = [
 | 
				
			||||||
            Permission.read(Role.user(loggedInUser["$id"])),
 | 
					            Permission.read(Role.user(loggedInUser["$id"])),
 | 
				
			||||||
            Permission.read(Role.team(r["$id"])),
 | 
					            Permission.read(Role.team(r["$id"])),
 | 
				
			||||||
            Permission.write(Role.team(r["$id"], 'owner')),
 | 
					            Permission.write(Role.team(r["$id"], "owner")),
 | 
				
			||||||
            Permission.delete(Role.team(r["$id"], 'owner'))
 | 
					            Permission.delete(Role.team(r["$id"], "owner")),
 | 
				
			||||||
          ];
 | 
					          ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          if (requireLoggedIn == false) {
 | 
					          if (requireLoggedIn == false) {
 | 
				
			||||||
            permissions.push(Permission.read(Role.any()));
 | 
					            permissions.push(Permission.read(Role.any()));
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          database.updateDocument(
 | 
					          database
 | 
				
			||||||
 | 
					            .updateDocument(
 | 
				
			||||||
              "tehillim-split",
 | 
					              "tehillim-split",
 | 
				
			||||||
              "lists",
 | 
					              "lists",
 | 
				
			||||||
              r["$id"],
 | 
					              r["$id"],
 | 
				
			||||||
              {},
 | 
					              {},
 | 
				
			||||||
              permissions,
 | 
					              permissions,
 | 
				
			||||||
          ).then(() => {
 | 
					            )
 | 
				
			||||||
            navigate('/list/' + r["$id"], {});
 | 
					            .then(() => {
 | 
				
			||||||
 | 
					              navigate("/list/" + r["$id"], {});
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        console.log(r);
 | 
					        console.log(r);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,14 @@
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
  import { Link } from "svelte-navigator";
 | 
					  import { Link } from "svelte-navigator";
 | 
				
			||||||
  import Header from "../../lib/Header.svelte";
 | 
					  import Header from "../../lib/Header.svelte";
 | 
				
			||||||
  import { database, loggedInUser, teams } from "../../lib/appwrite";
 | 
					  import {
 | 
				
			||||||
 | 
					    checkloggedin,
 | 
				
			||||||
 | 
					    database,
 | 
				
			||||||
 | 
					    loggedInUser,
 | 
				
			||||||
 | 
					    teams,
 | 
				
			||||||
 | 
					  } from "../../lib/appwrite";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  checkloggedin();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  export let id;
 | 
					  export let id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +42,7 @@
 | 
				
			||||||
          email,
 | 
					          email,
 | 
				
			||||||
          undefined,
 | 
					          undefined,
 | 
				
			||||||
          undefined,
 | 
					          undefined,
 | 
				
			||||||
          "http://localhost:5173/accept_list_invitation",
 | 
					          window.location.protocol + "//" + window.location.host + "/accept_list_invitation",
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        .then(() => getData());
 | 
					        .then(() => getData());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,7 +82,7 @@
 | 
				
			||||||
      type="button"
 | 
					      type="button"
 | 
				
			||||||
      to="/register{urlParams.get('redirect_uri') !== null
 | 
					      to="/register{urlParams.get('redirect_uri') !== null
 | 
				
			||||||
        ? '?redirect_uri=' + encodeURIComponent(urlParams.get('redirect_uri'))
 | 
					        ? '?redirect_uri=' + encodeURIComponent(urlParams.get('redirect_uri'))
 | 
				
			||||||
        : undefined}">Go to Register</Link
 | 
					        : ''}">Go to Register</Link
 | 
				
			||||||
    ><br />
 | 
					    ><br />
 | 
				
			||||||
    <p class="text-red-600" bind:this={error}></p>
 | 
					    <p class="text-red-600" bind:this={error}></p>
 | 
				
			||||||
  </fieldset>
 | 
					  </fieldset>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@
 | 
				
			||||||
    await account.updateName(name).catch((e) => (error.innerText = e));
 | 
					    await account.updateName(name).catch((e) => (error.innerText = e));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    account
 | 
					    account
 | 
				
			||||||
      .createVerification("http://localhost:5173/register/emailVerify")
 | 
					      .createVerification(window.location.protocol + "//" + window.location.host + "/register/emailVerify")
 | 
				
			||||||
      .then((r) => {
 | 
					      .then((r) => {
 | 
				
			||||||
        if (urlParams.get("redirect_uri") == null) {
 | 
					        if (urlParams.get("redirect_uri") == null) {
 | 
				
			||||||
          navigate("/", {});
 | 
					          navigate("/", {});
 | 
				
			||||||
| 
						 | 
					@ -79,7 +79,7 @@
 | 
				
			||||||
      type="button"
 | 
					      type="button"
 | 
				
			||||||
      to="/login{urlParams.get('redirect_uri') !== null
 | 
					      to="/login{urlParams.get('redirect_uri') !== null
 | 
				
			||||||
        ? '?redirect_uri=' + encodeURIComponent(urlParams.get('redirect_uri'))
 | 
					        ? '?redirect_uri=' + encodeURIComponent(urlParams.get('redirect_uri'))
 | 
				
			||||||
        : undefined}">Go to Log In</Link
 | 
					        : ''}">Go to Log In</Link
 | 
				
			||||||
    ><br />
 | 
					    ><br />
 | 
				
			||||||
    <p class="text-red-600" bind:this={error}></p>
 | 
					    <p class="text-red-600" bind:this={error}></p>
 | 
				
			||||||
  </fieldset>
 | 
					  </fieldset>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue