absmach / magistrala-ui

UI Repository for Magistrala IoT
9 stars 15 forks source link

[BUG] Redirect user to Domain Login before accessing any resources #156

Closed rodneyosodo closed 4 months ago

rodneyosodo commented 5 months ago

Is there an existing issue for this?

What were you trying to achieve?

I was testing Oauth2.0 and proviced an incorrect redirect URL to http://localhost:9095/ rather than http://localhost:9095/domains.

What are the expected results?

Since I have not logged in to any domain I should be redirected to domain login page and login first rather than showing the error

What are the received results?

Error page with somehow incorrect error message image

Steps To Reproduce

  1. Login with username and password
  2. Don't login to the domain
  3. Go to http://localhost:9095/ directly

In what environment did you encounter the issue?

Additional information you deem important

One way to solve this would be to inspect the token first and ascertain they have logged in to a domain. If not redirect them to domain login if yes proceed to giving them access on the requested resource

You can use the following json to reply the issue

Details ```json { "title": "issue 156", "steps": [ { "type": "setViewport", "width": 2030, "height": 1003, "deviceScaleFactor": 1, "isMobile": false, "hasTouch": false, "isLandscape": false }, { "type": "navigate", "url": "http://localhost:9095/domains", "assertedEvents": [ { "type": "navigation", "url": "http://localhost:9095/domains", "title": "Domains" } ] }, { "type": "navigate", "url": "http://localhost:9095/error?error=failed+to+retrieve+entity", "assertedEvents": [ { "type": "navigation", "url": "http://localhost:9095/error?error=failed+to+retrieve+entity", "title": "" } ] }, { "type": "click", "target": "main", "selectors": [ [ "aria/Back" ], [ "div.main-content a" ], [ "xpath//html/body/div[3]/div/div/div/div/a" ], [ "pierce/div.main-content a" ], [ "text/Back" ] ], "offsetY": 14.612579345703125, "offsetX": 452.78515625 }, { "type": "navigate", "url": "http://localhost:9095/domains", "assertedEvents": [ { "type": "navigation", "url": "http://localhost:9095/domains", "title": "Domains" } ] }, { "type": "click", "target": "main", "selectors": [ [ "aria/[role=\"button\"]" ], [ "div.itemsTable button" ], [ "xpath//html/body/div[3]/div/div/div/div[2]/div[2]/table/tbody/tr/td[6]/form/button" ], [ "pierce/div.itemsTable button" ] ], "offsetY": 12.2607421875, "offsetX": 33.8577880859375, "assertedEvents": [ { "type": "navigation", "url": "http://localhost:9095/?domain=433cd30f-8a6a-42d0-8610-9c63a7512ec2", "title": "" } ] } ] } ```