-
Notifications
You must be signed in to change notification settings - Fork 120
authentication
Lance Pollard edited this page Sep 24, 2012
·
2 revisions
class User extends Metro.Model
@embedsMany "authorizations"
@findFromSession: (session) ->
token = session?.cookies["connect.sid"]
return unless token
@where(persistentToken: token).first()
class Authorization extends Metro.Model
@embeddedIn "user"
class ApplicationController extends Metro.Controller
@beforeFilter "currentUser"
currentUser: ->
@currentUser ||= User.findFromSession(@session)
class AuthorizationsController extends ApplicationController
create: ->
@user = User.create(params.auth)
class SessionsController extends Metro.Controller
Some links on everyauth integration
- (everyauth config example)[https://github.com/viatropos/tower/issues/18#issuecomment-4278945]
- (init)[https://gist.github.com/2318237]
- (app)[https://gist.github.com/2318167]
- (User)[https://gist.github.com/2318251]
class Ability extends CanCan.Ability
constructor: (user) ->
if @user.admin
@can "update", Article
@can "read", Article
- if can "read", Article
ul
li Articles!
- if can "update", Article
input(type='submit', value='Save')