Skip to content

Commit

Permalink
chore: removed unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspardBBY committed Jan 14, 2024
1 parent c467fd7 commit a0b8468
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
22 changes: 3 additions & 19 deletions backend/src/route/AuthCallbackGET.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,13 @@ export default async function AuthCallbackGET(
// verify if user already have an user_profile (if new acc, create one)
let userProfileId = await getUserProfile(data.user.id);

let needInsertBoundService;
if (userProfileId) {
// Already account
const { alreadyBound, error } = await alreadyBoundService({
service: StreamingService.Spotify,
user_profile_id: userProfileId,
});
if (error) {
request.log.error("Impossible to fetch already bound services", error);
return response.code(500).send({ error: error });
}
needInsertBoundService = !alreadyBound;
} else {
if (!userProfileId) {
// New account
const { userProfileId: newUserProfileId, error } = await createAccount({
full_name: data.user.user_metadata.full_name,
account_id: data.user.id,
username: null,
});
needInsertBoundService = true;
if (error || !newUserProfileId) {
request.log.error("Impossible to create account: " + error);
return response.code(500).send({ error: error });
Expand All @@ -89,11 +76,8 @@ export default async function AuthCallbackGET(
});

if (error) {
const messageError = needInsertBoundService
? "Impossible to insert the new services."
: "Impossible to update service.";
request.log.error(messageError, error);
return response.code(500).send({ error: messageError });
request.log.error("Upsert impossible, ", error);
return response.code(500).send({ error: "Server error." });
}

const refresh_token = data.session.refresh_token;
Expand Down
4 changes: 2 additions & 2 deletions expo/app/(auth)/connect-with-spotify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function ConnectWithSpotify() {
"sb-" + supabaseProjectId + "-auth-token-code-verifier"
);
if (!codeVerifier) throw new Error("No codeVerifier");
const satanizedCodeVerifier = encodeURIComponent(
const urlEncodedCodeVerifier = encodeURIComponent(
codeVerifier.replace(/"/g, "")
);

Expand All @@ -58,7 +58,7 @@ export default function ConnectWithSpotify() {
":3000/auth/redirection?redirect_url=" +
data.url +
"#code_verifier=" +
satanizedCodeVerifier;
urlEncodedCodeVerifier;

const webBrowser = await WebBrowser.openAuthSessionAsync(
urlBackendRedirection,
Expand Down

0 comments on commit a0b8468

Please sign in to comment.