Skip to content

Commit

Permalink
fix:(reruin#378)stall.js
Browse files Browse the repository at this point in the history
  • Loading branch information
reruin committed Jan 25, 2021
1 parent 3d8e575 commit 7a3a535
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if(process.env.PORT){
const save = async (d) => db.set(d)

const installed = () => {
return db.get('path') && db.get('token')
return !!db.get('token')
}

const getConfig = (key) => db.get(key)
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module.exports = {
* Save config handler
*/
async save(ctx){
if(config.installed() ){
ctx.redirect('/')
}
let { token , name , path , vendor , title = 'ShareList'} = ctx.request.body
let cfg = {token , title}
if(Array.isArray(name)){
Expand Down
2 changes: 1 addition & 1 deletion app/middleware/koa-install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = require('../config')

module.exports = async (ctx , next)=>{
if(config.getPath().length){
if(config.installed()){
await next()
}else{
if( ctx.path != '/install'){
Expand Down

0 comments on commit 7a3a535

Please sign in to comment.