Skip to content

Commit

Permalink
Add counter/auth.md
Browse files Browse the repository at this point in the history
  • Loading branch information
James Carlson authored and James Carlson committed Jul 11, 2024
1 parent 1a18acc commit f97c125
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ ElmjutsuDumMyM0DuL3.elm

###
vendor-secret/
counter/
counter/src
counter/elm-stuff
103 changes: 103 additions & 0 deletions counter/auth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
```
```

# Summary of Auth Messages

## Phase I

1. `AuthFrontendMsg SubmitEmailForSignIn`
2. `AuthFrontendMsg (AuthSigninRequested { email = Just "[email protected]", methodId = "EmailMagicLink" })`

3. `AuthToBackend (AuthSigninInitiated { baseUrl = { fragment = Nothing, host = "localhost", path = "/admin", port_ = Just 8000, protocol = Http, query = Nothing }, methodId = "EmailMagicLink", username = Just "[email protected]" })`
4. `AuthToFrontend (ReceivedMessage (Ok "We have sent you a login email at [email protected]"))`

## Phase II

1. `AuthFrontendMsg (ReceivedSigninCode "14477875")`
2. `AuthToBackend (AuthSigInWithToken 14477875)`
3. `AuthToFrontend (AuthSignInWithTokenResponse (Ok { email = "[email protected]", name = "Jim Carlson", roles = [AdminRole,UserRole], username = "jxxcarlson" }))`
4. `SignInUser { email = "[email protected]", name = "Jim Carlson", roles = [AdminRole,UserRole], username = "jxxcarlson" }`


## Types

```
type FrontendMsg
= ...
| AuthFrontendMsg MagicLink.Types.Msg
type BackendMsg
= ...
| AuthBackendMsg Auth.Common.BackendMsg
type ToFrontend
= ...
| AuthToFrontend Auth.Common.ToFrontend
type ToBackend
= ...
| AuthToBackend Auth.Common.ToBackend
```

## Messages

```
-- FRONTEND
updateLoaded : FrontendMsg -> LoadedModel -> ( LoadedModel, Cmd FrontendMsg )
...
AuthFrontendMsg authToFrontendMsg ->
MagicLink.Auth.update authToFrontendMsg model.magicLinkModel
|> Tuple.mapFirst (\magicLinkModel -> { model | magicLinkModel = magicLinkModel })
updateFromBackendLoaded : ToFrontend -> LoadedModel -> ( LoadedModel, Cmd FrontendMsg )
...
AuthToFrontend authToFrontendMsg ->
MagicLink.Auth.updateFromBackend authToFrontendMsg model.magicLinkModel
|> Tuple.mapFirst
(\magicLinkModel -> { model | magicLinkModel = magicLinkModel })
-- BACKEND
update : BackendMsg -> BackendModel -> ( BackendModel, Cmd BackendMsg )
AuthBackendMsg authMsg ->
Auth.Flow.backendUpdate (MagicLink.Auth.backendConfig model)
updateFromBackendLoaded : ToFrontend -> LoadedModel -> ( LoadedModel, Cmd FrontendMsg )
AutoLogin sessionId loginData ->
( model, Lamdera.sendToFrontend sessionId (AuthToFrontend <| Auth.Common.AuthSignInWithTokenResponse <| Ok <| loginData) )
```

# Log


1. `F : AuthFrontendMsg SubmitEmailForSignIn`

2. `F : AuthFrontendMsg (AuthSigninRequested { email = Just "[email protected]", methodId = "EmailMagicLink" })`

3. `F▶️ : AuthToBackend (AuthSigninInitiated { baseUrl = { fragment = Nothing, host = "localhost", path = "/admin", port_ = Just 8000, protocol = Http, query = Nothing }, methodId = "EmailMagicLink", username = Just "[email protected]" })`

4. `▶️B: AuthToBackend (AuthSigninInitiated { baseUrl = { fragment = Nothing, host = "localhost", path = "/admin", port_ = Just 8000, protocol = Http, query = Nothing }, methodId = "EmailMagicLink", username = Just "[email protected]" })`

5. `◀️B: AuthToFrontend (ReceivedMessage (Ok "We have sent you a login email at [email protected]"))`

6. `F◀️: AuthToFrontend (ReceivedMessage (Ok "We have sent you a login email at [email protected]"))`

7. `F: AuthFrontendMsg (ReceivedSigninCode "14477875")`


8. `F▶️: AuthToBackend (AuthSigInWithToken 14477875)`


9. `▶️B: AuthToBackend (AuthSigInWithToken 14477875)`


10. `◀️B : AuthToFrontend (AuthSignInWithTokenResponse (Ok { email = "[email protected]", name = "Jim Carlson", roles = [AdminRole,UserRole], username = "jxxcarlson" }))`


11. `F◀️ : AuthToFrontend (AuthSignInWithTokenResponse (Ok { email = "[email protected]", name = "Jim Carlson", roles = [AdminRole,UserRole], username = "jxxcarlson" }))`

12. `F: SignInUser { email = "[email protected]", name = "Jim Carlson", roles = [AdminRole,UserRole], username = "jxxcarlson" }`

0 comments on commit f97c125

Please sign in to comment.