Skip to content

Commit d30a851

Browse files
committed
Finalize integration
1 parent 278d3df commit d30a851

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

feathers-chat-ts/src/authentication.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ declare module './declarations' {
88
}
99
}
1010

11-
const appId = 'did:key:z6MknavTx2wpQQVh8ENZAnbCJ2SbTftJVjMHJ8CUDFStk7Lf'
11+
const appId = 'did:key:z6Mkqo9vCYS8n5hFYjPX4YvDTBstj4dw6VoQY1ggrDJhVmxc'
1212

1313
class TalonStrategy extends AuthenticationBaseStrategy {
1414
verifier = createVerifier({ appId })
@@ -18,21 +18,17 @@ class TalonStrategy extends AuthenticationBaseStrategy {
1818
const { user: talonUser } = await this.verifier.verify(accessToken)
1919
const usersService = this.app!.service('users')
2020

21+
if (!talonUser) {
22+
throw new Error('Talon user not found')
23+
}
24+
25+
const { email } = talonUser
2126
// Find or create the user by email
2227
const users = await usersService.find({
23-
query: { email: talonUser!.email },
28+
query: { email },
2429
paginate: false
2530
})
26-
27-
let user
28-
if ((users as any[]).length > 0) {
29-
user = (users as any[])[0]
30-
} else {
31-
user = await usersService.create({
32-
email: talonUser!.email,
33-
avatar: `https://s.gravatar.com/avatar/${talonUser!.id}?s=60&d=mp`
34-
})
35-
}
31+
const user = users?.length > 0 ? users[0] : await usersService.create({ email })
3632

3733
return {
3834
authentication: { strategy: 'talon' },

public/index.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<title>feathers-chat</title>
55
<meta name="description" content="A Feathers chat application" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<link href="https://cdn.jsdelivr.net/npm/daisyui@2.46.1/dist/full.css" rel="stylesheet" type="text/css" />
8-
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2/dist/tailwind.min.css" rel="stylesheet" type="text/css" />
8+
<link
9+
href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2/dist/tailwind.min.css"
10+
rel="stylesheet"
11+
type="text/css"
12+
/>
913
<link rel="stylesheet" href="https://dove.feathersjs.com/feathers-chat.css" />
1014
</head>
1115
<body>
1216
<div id="app" data-theme="dracula"></div>
13-
<talon-login id="talon-login" app-id="did:key:z6MknavTx2wpQQVh8ENZAnbCJ2SbTftJVjMHJ8CUDFStk7Lf" hidden></talon-login>
17+
<talon-login
18+
id="talon-login"
19+
app-id="did:key:z6Mkqo9vCYS8n5hFYjPX4YvDTBstj4dw6VoQY1ggrDJhVmxc"
20+
></talon-login>
1421
<script type="module" src="https://esm.sh/talon-auth/login"></script>
1522
<script src="https://unpkg.com/@feathersjs/client@^5.0.0-pre.34/dist/feathers.js"></script>
1623
<script src="/socket.io/socket.io.js"></script>

0 commit comments

Comments
 (0)