gitoria

ident

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit45e5530345e55303ident#42: an app write patches one row: upsert on create, edit and new secret, one-argument remove on delete; the faces answer the changed app (or the deleted id), not the whole listmre45e55303/components/chooseidentity.hl

2.4 KB

  1. // components/chooseidentity.hl — THE APP'S IDENTITY CHOICE (ident#40.3), placed by components/home.hl on `/signin/<rid>`: which identity
  2. // signs in to the app that sent the browser here. The host passes in the login request (rid), the app's name and the rows (identities).
  3. // A click asks the server for the app's return URL with a one-time code (face chooseIdentity, lib/apps.hl grantRequest: a plain
  4. // login, or an invite's) and the browser goes there. The host shows the messages: $parent.status(message, notice).
  5. import { accountOfSession } from '../lib/accounts.hl'
  6. import { grantRequest } from '../lib/apps.hl'
  7. import { leadLook, avatarLook } from './styles.hl'
  8. rid = null
  9. appName = ''
  10. identities = []
  11. Style {
  12. pLead = leadLook
  13. pAvatar = avatarLook
  14. '#chooselist img' {
  15. width = '32px'
  16. height = '32px'
  17. }
  18. }
  19. View {
  20. section { id = "choosesection"
  21. h1 { "Choose an identity" }
  22. p { Style.pLead "Which identity signs in to " strong { appName } "? The app gets only the identity's short id — no email, no names." }
  23. ul { id = "chooselist"
  24. for (row of identities) {
  25. li {
  26. if (row.hasAvatar) { img { Style.pAvatar src = row.avatar alt = "" width = "32" height = "32" } }
  27. identityMain {
  28. identityLabel { row.label }
  29. identityShortId { row.shortId }
  30. if (row.isDefault) { defaultBadge { "default" } }
  31. identityDetails { row.details }
  32. }
  33. button { type = "button" class = "choose" value = row.id "Continue" on click(e) { emit choose(e.target.value) } }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. // THE CHOICE: the server makes (or finds) this identity's id for the app and answers
  40. // the app's return URL with a one-time code — the browser goes there
  41. on choose(id) {
  42. $parent.status('', '')
  43. r = emit server chooseIdentity(rid, '' + id)
  44. if (r == null) {
  45. $parent.status('the server did not answer — try again', '')
  46. return null
  47. }
  48. if (r.error != null) {
  49. $parent.status(r.error, '')
  50. return null
  51. }
  52. $parent.status('', 'Back to ' + appName + ' …')
  53. window.location.assign(r.url)
  54. }
  55. // the identity for the app's login request (lib/apps.hl grantRequest): { url } or { error }
  56. on server chooseIdentity(rid, identity, session) {
  57. let me = accountOfSession(&session)
  58. if (me == null) { return { error = 'you are not signed in' } }
  59. if (rid == null || hlTypeName(rid) != 'String') { return { error = 'field rid must be a string' } }
  60. if (identity == null || hlTypeName(identity) != 'String') { return { error = 'field identity must be a string' } }
  61. return grantRequest(me.id, rid, identity)
  62. }

Branches

Latest commits

  • 45e55303ident#42: an app write patches one row: upsert on create, edit and new secret, one-argument remove on delete; the faces answer the changed app (or the deleted id), not the whole listmre
  • 991641d4Merge branch 'f10-access' into mainIdent
  • e56d8273|||PR ident#34 part 4: access and inbox fixed classesmre
  • df7696dbident#34: tests: access ticks selector quoting fixmre
  • 7215903eident#34: access: the unstyled classes all, app, tick, apptick, plus are dropped; the gate finds the app ticks by input[name=app]mre
  • 69b0a0ceident#34: access: the pick buttons use Style.pickCard instead of class pickmre
  • dc702419Merge branch 'f9-choose' into mainIdent
  • 8caec771|||PR ident#34 restore .choose hookmre
  • 0dbff960Merge branch 'f8-shared' into mainIdent
  • d69665f6|||PR ident#34 part 3: shared look classes (wide, avatar, chip/used, conn, choose, who, inboxlink) moved to statics or droppedmre
  • 3a64dc48ident#34: chipLook: radius as the same var() string (a bare token name in a static does not compile); selector gate selectormre
  • eb039073ident#34: tests: signin and migration find the choice without the classmre
  • 4b94a594ident#34: tests: fix selector of the identity choicemre
  • bebc88e4ident#34: main.hl drops the unstyled classes inboxlink and whomre
  • b4e7ad04ident#34: the identity choice link/button has no class (rule on #chooselist a)mre
  • 3c33d6eaident#34: the connection link in inbox has no class (rule on #conns a)mre
  • dc97ec0dident#34: the Notif. chip and the Used in link share chipLook (Style.pChip) instead of the classes chip/used/notifmre
  • 378bd432ident#34: the identity picture look is a static in styles.hl (Style.pAvatar); sizes stay with each listmre
  • 1cf79e7eident#34: the wide page column is a static in styles.hl (Style.pWide), not the class "wide"mre
  • ddc7d135Merge branch 'f7-hooks' into mainIdent