Skip to content

Commit 9bd4024

Browse files
committed
changes in separation of authn code part2
1 parent a1b5a39 commit 9bd4024

11 files changed

Lines changed: 241 additions & 129 deletions

src/acl/add-agent-buttons.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { AccessGroups } from './access-groups'
77
import { icons } from '../iconBase'
88
import * as widgets from '../widgets'
99
import * as ns from '../ns'
10-
import { authn, AuthenticationContext } from 'solid-logic'
10+
import { AuthenticationContext, solidLogicSingleton } from 'solid-logic'
1111
import * as utils from '../utils'
1212
import { NamedNode, Store } from 'rdflib'
1313
// import { AuthenticationContext } from '../authn/types'
1414
import * as debug from '../debug'
15+
import { loggedInContext } from '../login/login'
1516

1617
/**
1718
* Renders the Sharing pane's "+" button and the menus behind it,
@@ -184,7 +185,17 @@ export class AddAgentButtons {
184185
}
185186

186187
private async renderAppsTable (eventContext: AuthenticationContext): Promise<string> {
187-
await authn.logInLoadProfile(eventContext)
188+
const newContext = await loggedInContext(eventContext)
189+
if (newContext.me) {
190+
eventContext.publicProfile = await solidLogicSingleton.loadProfile(newContext.me!)
191+
} else {
192+
if (eventContext.div && eventContext.dom) {
193+
eventContext.div.appendChild(
194+
widgets.errorMessageBlock(eventContext.dom, 'Could not log in!')
195+
)
196+
}
197+
}
198+
// await authn.logInLoadProfile(eventContext)
188199
const trustedApps = (this.groupList.store as Store).each(eventContext.me, ns.acl('trustedApp')) as Array<NamedNode> // @@ TODO fix as
189200
const trustedOrigins = trustedApps.flatMap(app => (this.groupList.store as Store).each(app, ns.acl('origin'))) // @@ TODO fix as
190201

src/chat/bookmarks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as style from '../style'
1414
import * as utils from '../utils'
1515
import * as widgets from '../widgets'
1616
import { authn, store } from 'solid-logic'
17+
import { findAppInstances } from '../login/login'
1718

1819
const UI = { icons, ns, media, pad, rdf, store, style, utils, widgets }
1920
const $rdf = UI.rdf
@@ -96,7 +97,7 @@ export async function findBookmarkDocument (userContext) {
9697
const fileTail = 'bookmarks.ttl'
9798
const isPublic = true
9899

99-
await authn.findAppInstances(userContext, theClass, isPublic) // public -- only look for public links
100+
await findAppInstances(userContext, theClass, isPublic) // public -- only look for public links
100101
if (userContext.instances && userContext.instances.length > 0) {
101102
userContext.bookmarkDocument = userContext.instances[0]
102103
if (userContext.instances.length > 1) {

src/chat/infinite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export async function infiniteMessageArea (dom, kb, chatChannel, options) {
324324
} // turn on inpuut
325325

326326
const context = { div: middle, dom: dom }
327-
login.logIn(context).then(context => {
327+
login.loggedInContext(context).then(context => {
328328
me = context.me
329329
turnOnInput()
330330
Object.assign(context, userContext)

src/create/create.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as utils from '../utils'
88
import * as widgets from '../widgets'
99
import * as ns from '../ns'
1010
import { authn, solidLogicSingleton } from 'solid-logic'
11-
import { selectWorkspace } from '../login/login'
11+
import { loggedInContext, selectWorkspace } from '../login/login'
1212
// import { logInLoadProfile, selectWorkspace } from '../authn/authn'
1313
import { DataBrowserContext, NewPaneOptions, PaneDefinition } from 'pane-registry'
1414
import { CreateContext, NewAppInstanceOptions } from './types'
@@ -79,8 +79,12 @@ export function newThingUI (
7979
return new Promise(function (resolve, reject) {
8080
let selectUI // , selectUIParent
8181
function callbackWS (ws, newBase) {
82-
authn.logInLoadProfile(createContext).then(
82+
loggedInContext(createContext).then(
8383
_context => {
84+
// load profile
85+
if (_context.me) {
86+
solidLogicSingleton.loadProfile(_context.me!)
87+
}
8488
const newPaneOptions: NewPaneOptions = Object.assign({
8589
newBase: newBase,
8690
folder: options.folder || undefined,

0 commit comments

Comments
 (0)