Skip to content

Commit

Permalink
Merge pull request #4 from dragoni7/OAuth
Browse files Browse the repository at this point in the history
OAuth
  • Loading branch information
dragoni7 authored Jun 25, 2024
2 parents 5135f3b + 37d7970 commit 6ec0ccd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
31 changes: 22 additions & 9 deletions src/app/routes/Landing.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useNavigate } from 'react-router'

import { useEffect} from "react"
import React, { useEffect} from "react"
import BungieLogin from '../../features/auth/BungieLogin'
import { regenerateTokens } from '../../lib/bungie_api/TokenService'
import { isAuthenticated } from '../../lib/bungie_api/AuthService'

import { Container, Grid, Paper } from '@mui/material'

export const LandingRoute = () => {

Expand All @@ -24,15 +24,28 @@ export const LandingRoute = () => {
else {
console.log("Not authenticated")
}
}, 50)
}, 300)
}, [])

return (
<div>
Welcome
<br />
Log in to use app
<BungieLogin />
</div>
<React.Fragment>
<Container maxWidth='md'>
<Paper elevation={8} square={false} sx={{bgcolor:'#375873', marginTop: 10 }}>
<Grid container spacing={3} direction={"column"} justifyContent={"space-around"} alignItems={'center'} padding={6}>
<Grid item md={12} marginBottom={12}>
<h1>
D2Loadouts
</h1>
</Grid>
<Grid item md={12}>
D2Loadouts requires permission to read your Destiny 2 information
</Grid>
<Grid item md={3}>
<BungieLogin />
</Grid>
</Grid>
</Paper>
</Container>
</React.Fragment>
)
}
2 changes: 1 addition & 1 deletion src/features/auth/BungieLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const BungieLogin: React.FC = () => {
authenticate()
}

return ( <button onClick={onLogIn}>Log In</button> )
return ( <button onClick={onLogIn}>Authorize with Bungie.net</button> )
}

export default BungieLogin
2 changes: 1 addition & 1 deletion src/lib/bungie_api/TokenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function regenerateTokens(): boolean {
}

export function generateToken(refresh: boolean, authCode=""): Tokens | null {
const REFRESH_TOKEN = getTokens()?.refreshToken
const REFRESH_TOKEN = getTokens()?.refreshToken?.value
var returnToken = null

let body = refresh === false ?
Expand Down

0 comments on commit 6ec0ccd

Please sign in to comment.