-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from ellielle/boss-tab
- Loading branch information
Showing
9 changed files
with
138 additions
and
96 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 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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<script> | ||
import { User } from "../../stores/user"; | ||
$: username = $User.userData.DiscordUserHandle; | ||
</script> | ||
|
||
<main> | ||
Welcome to Boot.dev Buddy, {$User.userData.DiscordUserHandle}! | ||
{console.log($User)} | ||
Welcome to Boot.dev Buddy, {username}! | ||
</main> |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/ellielle/bootdev-buddy/internal/login" | ||
) | ||
|
||
// LoginUserWithOTP takes the user's one-time password and exchanges it | ||
// for an access_token and refresh_token from Boot.Dev | ||
func (a *App) LoginUserWithOTP(OTP string) (bool, error) { | ||
tokens, err := login.ExchangeOTPForToken(OTP) | ||
if err != nil { | ||
return false, errors.New("error exchanging OTP for Token") | ||
} | ||
if tokens.AccessToken == "" { | ||
return false, errors.New("empty token after exchanging with OTP") | ||
} | ||
|
||
err = login.SaveTokens(tokens) | ||
if err != nil { | ||
return false, err | ||
} | ||
// set token in App struct so it can be used for | ||
// user-specific queries | ||
a.tokens = *tokens | ||
|
||
return true, nil | ||
} | ||
|
||
func (a *App) LoginUserWithToken() (bool, error) { | ||
// Don't waste calls and assume the 1 hour token is invalid | ||
tokens, err := login.RefreshToken() | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
a.tokens = *tokens | ||
|
||
return true, nil | ||
} |
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,48 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/ellielle/bootdev-buddy/internal/bootdevapi" | ||
) | ||
|
||
// GetArchmagesList returns the data from the archmage leaderboard | ||
func (a *App) ArchmagesList() []bootdevapi.Archmage { | ||
list, err := bootdevapi.Archmages(a.cache) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
return list | ||
} | ||
|
||
// GlobalStats returns the general global stats from the leaderboard | ||
func (a *App) GlobalStats() bootdevapi.GlobalStats { | ||
stats, err := bootdevapi.GetGeneralStats(a.cache) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
return stats | ||
} | ||
|
||
// TopDailyLearners returns the top 30 users based on exp earned | ||
func (a *App) TopDailyLearners() []bootdevapi.LeaderboardUser { | ||
list, err := bootdevapi.GetDailyStats(a.cache) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
return list | ||
} | ||
|
||
// TopCommunity returns the top 30 members of the discord community, | ||
// based on a variety of factors such as activity | ||
func (a *App) TopCommunity() []bootdevapi.Archon { | ||
list, err := bootdevapi.GetDiscordLeaderboard(a.cache) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
return list | ||
} |