Skip to content

Commit

Permalink
refactor: prepare naive apple sign-in
Browse files Browse the repository at this point in the history
  • Loading branch information
ohrstrom committed Dec 13, 2023
1 parent cdaefc8 commit a437674
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
10 changes: 8 additions & 2 deletions obr_ui/app-bridge/appBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type sendChannel =
// browser
| "browser:navigate"
// sign-in
| "googleSignin:start";
| "googleSignin:start"
| "appleSignin:start";

// channels RECEIVING data FROM swift-app
type receiveChannel =
Expand All @@ -76,7 +77,8 @@ type receiveChannel =
// appscene
| "appscene:update"
// sign-in
| "googleSignin:completed";
| "googleSignin:completed"
| "appleSignin:completed";

type SendMessage = {
c: sendChannel;
Expand Down Expand Up @@ -250,6 +252,10 @@ class AppBridge {
await this.loginByIdToken(data);
break;
}
case "appleSignin:completed": {
console.debug("appleSignin:completed", data);
break;
}
}
}
async onExternalLink(e: Event) {
Expand Down
13 changes: 10 additions & 3 deletions obr_ui/components/account/auth/SocialLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export default defineComponent({
};
const availableBackends = computed(() => {
// NOTE: temporarily disable oauth2 for app versions prior to 1.0.1
if (isApp && appVersion?.major !== 1) {
if (isApp && appVersion?.major === 1 && appVersion?.minor === 0 && appVersion?.patch < 1) {
return authBackends.value.filter((b) => b.provider !== "google-oauth2");
}
// NOTE: temporarily disable apple-id for app-mode
if (isApp) {
// NOTE: temporarily disable apple-id for app versions prior to 1.0.3
if (isApp && appVersion?.major === 1 && appVersion?.minor === 0 && appVersion?.patch < 3) {
return authBackends.value.filter((b) => b.provider !== "apple-id");
}
return authBackends.value;
Expand All @@ -71,6 +71,13 @@ export default defineComponent({
return;
}
if (isApp && backend.provider === "apple-id") {
console.debug("continue with app native apple-id login");
iOSMaskVisible.value = true;
window.appBridge?.send("appleSignin:start");
return;
}
const connectUrl = backend.connectUrl;
const params: { [x: string]: string } = {};
if (props.next) {
Expand Down
2 changes: 1 addition & 1 deletion obr_ui/composables/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const parseAppUA = (ua: string): null | AppVersion => {
if (!ua.toLowerCase().startsWith("obr-app-ios/")) {
return null;
}
const semVer = semverCoerce(ua.substring(12));
const semVer = semverCoerce(ua.substring(11));
if (!semVer) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions obr_ui/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ menu:
home: Radio
discover: Discover
collection: Favourites
program: Program
program: Programme
reception: Reception
faq: FAQ
about: About
Expand Down Expand Up @@ -58,7 +58,7 @@ player:
bannedRemove: I like it
rating:
downvoteTitle: What bothers you?
downvoteLead: In order to constantly improve the radio program, we need your feedback!
downvoteLead: In order to constantly improve the radio programme, we need your feedback!
downvoteScope:
track: I don't like this title
genre: I don't like this kind of music
Expand Down

0 comments on commit a437674

Please sign in to comment.