marc-campbell / nicedishy-macos

The MacOS client for nicedishy.com
https://nicedishy.com
2 stars 0 forks source link

Build the "Log In" functionality #1

Closed marccampbell closed 2 years ago

marccampbell commented 2 years ago

Change "Log In" to "Connect Dishy"

When selecting this from the menu bar, a new modal window should be shown. The screen will provide a little text, and ask the user to paste in their Dishy Token. There should be a link to "https://nicedishy.com" on this page to get the token if the user needs.

Once there's a token provided, attempt to validate it by calling https://api.nicedishy.com/v1/dishy as a GET request with the token in the Authorization header ("Authorization: Token abided"). The response should be a 200 OK with a JSON payload.

The JSON payload can be ignored.

Once logged in with a token, the token can be added to all future API requests.

The "Connect Dishy" menubar item should be removed once logged in, and replaced with a "Disconnect Dishy" item.

When selecting "Disconnect Dishy", the token should be removed.

dnshzdev commented 2 years ago

I think that it would be better if "Connect Dish" opens a web browser visiting "https://nicedishy.com", instead of a modal window asking the user to enter the token. IF On web browser, the user logs in and get the token, and redirect to a special scheme headed link, in the form of nicedishy://success?token=<...>, then macOS app is able to catch the token automatically.

marccampbell commented 2 years ago

I love that idea :). Let's do it! What do you need from the web side?

If you visit: https://nicedishy.com/connect_device Let's assume that this URL will open a list of devices and the user will select one. After that, the browser will be redirected to nicedishy://connected?token=abc

If that custom URL scheme doesn't work, Let me know. I'll work on that this afternoon

dnshzdev commented 2 years ago

The custom URL scheme will work.

marccampbell commented 2 years ago

@dnshzdev This is live on https://nicedishy.com now. You should be able to log in and select a dish and receive the redirect token

dnshzdev commented 2 years ago

Great, I will work on it and update as soon as possible.