Skip to content

Commit 830fabd

Browse files
committed
adding router to the solid-server to support account recovery
1 parent 2219618 commit 830fabd

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

lib/account-recovery.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ function AccountRecovery (corsSettings, options = {}) {
3434
const ldp = req.app.locals.ldp
3535
const emailService = req.app.locals.email
3636

37-
if (!req.body.account) {
38-
res.send(406)
39-
return
40-
}
37+
// if (!req.body.account) {
38+
// res.status(406).send('You need to pass an account')
39+
// return
40+
// }
4141

4242
// Check if account exists
4343
ldp.graph(req.body.account, '/' + ldp.suffixAcl, function (err, graph) {
4444
if (err) {
45-
res.send(err.status, 'Fail to find user')
45+
// console.log("answer back:", err)
46+
res.status(err.status || 500).send('Fail to find user')
4647
return
4748
}
4849

@@ -58,7 +59,7 @@ function AccountRecovery (corsSettings, options = {}) {
5859
})
5960

6061
if (!emailAddress) {
61-
res.send(406, 'No emailAddress registered in your account')
62+
res.status(406).send('No emailAddress registered in your account')
6263
return
6364
}
6465

@@ -77,7 +78,7 @@ function AccountRecovery (corsSettings, options = {}) {
7778

7879
router.get('/confirm', function (res, req, next) {
7980
if (!req.query.token) {
80-
res.send(406, 'Token is required')
81+
res.status(406).send('Token is required')
8182
return
8283
}
8384

lib/create-app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var IdentityProvider = require('./identity-provider')
1111
var vhost = require('vhost')
1212
var path = require('path')
1313
var EmailService = require('./email-service')
14+
const AccountRecovery = require('./account-recovery')
1415

1516
var corsSettings = cors({
1617
methods: [
@@ -83,6 +84,11 @@ function createApp (argv = {}) {
8384
proxy(app, ldp.proxy)
8485
}
8586

87+
if (ldp.webid) {
88+
var accountRecovery = AccountRecovery(corsSettings, { redirect: '/' })
89+
app.use('/recovery', accountRecovery)
90+
}
91+
8692
// Adding Multi-user support
8793
if (ldp.webid) {
8894
var idp = IdentityProvider({

lib/token-service.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const moment = require('moment')
44
const uid = require('uid-safe').sync
55
const extend = require('extend')
66

7-
module.exports = TokenService
8-
97
class TokenService {
108
constructor () {
119
this.tokens = {}
@@ -32,3 +30,5 @@ class TokenService {
3230
delete this.tokens[token]
3331
}
3432
}
33+
34+
module.exports = TokenService

static/account-recovery.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<h2>Recover your account</h2>
4242
<input id="account" type="account" placeholder="Enter your account address">
4343
<br>
44-
<button onclick='retrieveAccount()'>Create account</button>
44+
<button onclick='retrieveAccount()'>Retrieve account</button>
4545
</div>
4646

4747
<script type="text/javascript">

0 commit comments

Comments
 (0)