Skip to content

Commit

Permalink
update authorize flow
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-teddy committed Feb 2, 2024
1 parent 8c7be13 commit eaa064c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/state.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { atom, selector, selectorFamily } from "recoil";
import { authorize, getLocation, getPhoneNumber, getUserInfo } from "zmp-sdk";
import {
authorize,
getLocation,
getPhoneNumber,
getSetting,
getUserInfo,
} from "zmp-sdk";
import logo from "static/logo.png";
import { Category } from "types/category";
import { Product, Variant } from "types/product";
Expand All @@ -13,10 +19,12 @@ import categories from "../mock/categories.json";

export const authorizedState = selector({
key: "authorized",
get: () =>
authorize({
scopes: ["scope.userLocation", "scope.userPhonenumber"],
}),
get: async () => {
const { authSetting } = await getSetting({});
if (!authSetting["scope.userInfo"]) {
await authorize({ scopes: [] });
}
},
});

export const userState = selector({
Expand Down

0 comments on commit eaa064c

Please sign in to comment.