aboutsummaryrefslogtreecommitdiffstats
path: root/postcss.config.cjs
diff options
context:
space:
mode:
Diffstat (limited to 'postcss.config.cjs')
0 files changed, 0 insertions, 0 deletions
18029c471'>60f21d29 ^
99b32961 ^
60f21d29 ^



74978738 ^
99b32961 ^
74978738 ^
5daf37ea ^
74978738 ^



5c5ae752 ^
21b7bf46 ^
5c5ae752 ^






5c5ae752 ^


74978738 ^
8e2f50f4 ^

17292a0c ^
8e2f50f4 ^
5255f026 ^
8e2f50f4 ^

514b869f ^
514b869f ^

74978738 ^


60029a8f ^


74978738 ^
5c5ae752 ^
74978738 ^
3b565f4f ^
99b32961 ^

ed4a64c6 ^


3b565f4f ^







ed4a64c6 ^
9ce3e483 ^
9edc8a78 ^


0467f611 ^
9edc8a78 ^
ed4a64c6 ^

9ce3e483 ^
ed4a64c6 ^
74978738 ^


17292a0c ^
74978738 ^
5255f026 ^
74978738 ^



17292a0c ^
05931702 ^

99b32961 ^
05931702 ^
42dee71e ^






74978738 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
                        

                          
                              
                       
                                                     



                                                            
                     
                                                     
                            
                                                               



                                    
                       
          






                                    


                      
                     

                                                     
                                 
                                 
                          

           
                                   

                      


                    


                            
     
 
                       
                 

                                       


                                       







                                                
                                                         
                                   


                                         
                                  
                

                                                                   
            
         


                     
                             
                             
                      



                                                          
                                

                              
                                                  
                               






                                                             
     
db = require("../redis")
bcrypt = require('bcrypt')

module.exports = (sessions) ->
  exists: (req, res) ->
    db.hgetall("user:"+req.params.user, (err, obj) ->
      if obj? then res.write('true') else res.write('false')
      res.end()
    )
  
  json: (req, res) ->
    db.hgetall("user:"+req.params.user, (err, obj) ->
      delete obj['password']
      res.writeHead(200, {"Content-Type": "application/json"});
      res.write(JSON.stringify(obj))
      res.end()
    )

  index: (req, res) -> 
    return
    db.keys('*', (err, obj) ->
      res.write(JSON.stringify(obj))
      res.end()
    )

  list: (req, res) ->
    res.render('users/index', 
      layout: 'layout'
    )

  show: (req, res) ->
    db.hgetall("user:"+req.params.user, (err, obj) ->
      if obj 
        res.render('users/show', 
          user: req.params.user, 
          layout: 'layout'
        )
      else 
        res.render('sessions/new', 
          notice: true
        )
    )

  new: (req, res) ->
    res.render('users/new', 
      js: (-> global.js), 
      css: (-> global.css)
    )

  create: (req, res) ->
    errormsg = ""
    userkey = "user:"+req.body.username
    db.hgetall(userkey, (err, obj) ->
      if obj
        res.redirect(req.body.username)
      else
        if req.body.confirm != req.body.password
          errormsg += "Passwords must match"
          return res.render('users/new',
            js: (-> global.js), 
            css: (-> global.css),
            error: errormsg
          )

        bcrypt.hash(req.body.password, 12, (err, hash) ->
           db.sadd("users",userkey)
           db.hmset(userkey,
             username: req.body.username,
             password: hash,
             email: req.body.email
            , ->
              req.headers['referer'] = "/#{req.body.username}/edit"
              sessions.create(req, res)
           )
        )
    )

  edit: (req, res) ->
    res.render('users/edit', 
      user: req.params.user, 
      layout: 'layout'
    )

  update: (req, res) ->
    return unless req.params.user is req.user.username or 
    req.user.username is 'admin'
    if req.body.password is ''
      delete req.body.password
    db.hmset("user:"+req.params.user, req.body, ->
      if not req.body.password?
        res.redirect("/#{req.params.user}")
      else
        bcrypt.hash(req.body.password, 12, (err, hash) ->
          db.hmset("user:"+req.params.user,password: hash, ->
            res.redirect("/#{req.params.user}")
          )
        )
    )