Skip to content

Commit

Permalink
Restrict login and signup from accessing while holding session
Browse files Browse the repository at this point in the history
  • Loading branch information
Dusan Stevanovic committed Jan 3, 2023
1 parent 5f74e25 commit df009ab
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 18 deletions.
44 changes: 32 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7693,24 +7693,44 @@ var $author$project$Main$urlToPage = F2(
switch (_v0.a.$) {
case 'Login':
var _v1 = _v0.a;
return $author$project$Main$LoginPage(
$author$project$Login$init(_Utils_Tuple0).a);
var _v2 = $author$project$Credentials$fromSessionToToken(session);
if (_v2.$ === 'Just') {
return $author$project$Main$NotFoundPage;
} else {
return $author$project$Main$LoginPage(
$author$project$Login$init(_Utils_Tuple0).a);
}
case 'Signup':
var _v2 = _v0.a;
return $author$project$Main$SignupPage(
$author$project$Signup$init(_Utils_Tuple0).a);
var _v3 = _v0.a;
var _v4 = $author$project$Credentials$fromSessionToToken(session);
if (_v4.$ === 'Just') {
return $author$project$Main$NotFoundPage;
} else {
return $author$project$Main$SignupPage(
$author$project$Signup$init(_Utils_Tuple0).a);
}
case 'Profile':
return $author$project$Main$ProfilePage(
$author$project$Profile$init(session).a);
var _v5 = $author$project$Credentials$fromSessionToToken(session);
if (_v5.$ === 'Just') {
return $author$project$Main$ProfilePage(
$author$project$Profile$init(session).a);
} else {
return $author$project$Main$NotFoundPage;
}
case 'Verification':
var _v6 = $author$project$Credentials$fromSessionToToken(session);
if (_v6.$ === 'Just') {
return $author$project$Main$VerificationPage(
A2($author$project$Verification$init, session, url.path).a);
} else {
return $author$project$Main$NotFoundPage;
}
case 'Home':
var _v3 = _v0.a;
var _v7 = _v0.a;
return $author$project$Main$HomePage(
$author$project$Home$init(_Utils_Tuple0).a);
case 'Verification':
return $author$project$Main$VerificationPage(
A2($author$project$Verification$init, session, url.path).a);
default:
var _v4 = _v0.a;
var _v8 = _v0.a;
return $author$project$Main$NotFoundPage;
}
} else {
Expand Down
32 changes: 26 additions & 6 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,39 @@ urlToPage : Url -> Session -> Page
urlToPage url session =
case Parser.parse matchRoute url of
Just Login ->
LoginPage (Tuple.first (Login.init ()))
case fromSessionToToken session of
Just _ ->
NotFoundPage

Nothing ->
LoginPage (Tuple.first (Login.init ()))

Just Signup ->
SignupPage (Tuple.first (Signup.init ()))
case fromSessionToToken session of
Just _ ->
NotFoundPage

Nothing ->
SignupPage (Tuple.first (Signup.init ()))

Just (Profile _) ->
ProfilePage (Tuple.first (Profile.init session))
case fromSessionToToken session of
Just _ ->
ProfilePage (Tuple.first (Profile.init session))

Just Home ->
HomePage (Tuple.first (Home.init ()))
Nothing ->
NotFoundPage

Just (Verification _) ->
VerificationPage (Tuple.first (Verification.init session url.path))
case fromSessionToToken session of
Just _ ->
VerificationPage (Tuple.first (Verification.init session url.path))

Nothing ->
NotFoundPage

Just Home ->
HomePage (Tuple.first (Home.init ()))

Just NotFound ->
NotFoundPage
Expand Down

0 comments on commit df009ab

Please sign in to comment.