Update to make standardized API endpoints
This commit is contained in:
		
							parent
							
								
									8e45f66786
								
							
						
					
					
						commit
						7457b39774
					
				
					 4 changed files with 4 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -12,7 +12,7 @@
 | 
			
		|||
  </div>
 | 
			
		||||
  <a
 | 
			
		||||
    class="flex w-full p-2 font-mono text-lg md:p-4 md:text-2xl bg-secondary ring-2 ring-secondary/80 h-fit0 hover:bg-secondary/50"
 | 
			
		||||
    href="http://localhost:31337/login"
 | 
			
		||||
    href="http://localhost:31337/auth/login"
 | 
			
		||||
  >
 | 
			
		||||
    <div class="w-full h-full text-center bg-primary">
 | 
			
		||||
      <p class="drop-shadow-accent drop-shadow-md">Login with Discord</p>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,10 @@
 | 
			
		|||
export function isLoggedIn(): Promise<boolean> {
 | 
			
		||||
  return fetch('http://localhost:31337/authorized', {
 | 
			
		||||
  return fetch('http://localhost:31337/get/user/authorized', {
 | 
			
		||||
    credentials: 'include',
 | 
			
		||||
  })
 | 
			
		||||
    .then((res) => {
 | 
			
		||||
      return res.json().then((res_json) => {
 | 
			
		||||
        const is_authorized = res_json.message
 | 
			
		||||
        console.log('whwhwhw' + is_authorized)
 | 
			
		||||
        return Boolean(is_authorized)
 | 
			
		||||
      })
 | 
			
		||||
    })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,19 +9,17 @@ export const user_store = reactive({
 | 
			
		|||
})
 | 
			
		||||
 | 
			
		||||
export function update_info() {
 | 
			
		||||
  fetch('http://localhost:31337/dashboard', {
 | 
			
		||||
  fetch('http://localhost:31337/get/user/info', {
 | 
			
		||||
    credentials: 'include',
 | 
			
		||||
  })
 | 
			
		||||
    .then((res) => {
 | 
			
		||||
      res
 | 
			
		||||
        .json()
 | 
			
		||||
        .then((userjson) => {
 | 
			
		||||
          console.log(userjson)
 | 
			
		||||
          user_store.avatar_decoration =
 | 
			
		||||
            'https://cdn.discordapp.com/avatar-decoration-presets/' +
 | 
			
		||||
            userjson.avatar_decoration_data.asset +
 | 
			
		||||
            '.png'
 | 
			
		||||
          console.log(user_store)
 | 
			
		||||
          user_store.avatar =
 | 
			
		||||
            'https://cdn.discordapp.com/avatars/' + userjson.id + '/' + userjson.avatar + '.png'
 | 
			
		||||
          user_store.id = 'https://discord.com/users/' + userjson.id
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ onMounted(update_info)
 | 
			
		|||
        </div>
 | 
			
		||||
        <a
 | 
			
		||||
          class="flex w-full p-2 font-mono text-lg md:p-4 md:text-2xl bg-secondary ring-2 ring-secondary/80 h-fit0 hover:bg-secondary/50"
 | 
			
		||||
          href="http://localhost:31337/logout"
 | 
			
		||||
          href="http://localhost:31337/auth/logout"
 | 
			
		||||
        >
 | 
			
		||||
          <div class="w-full h-full text-center bg-primary">
 | 
			
		||||
            <p class="drop-shadow-accent drop-shadow-md">Logout</p>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue