Created
April 20, 2012 14:19
-
-
Save Akkuma/2429021 to your computer and use it in GitHub Desktop.
Tower.js Passport Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passport = require 'passport' | |
googOID = require('passport-google').Strategy | |
steamOID = require('passport-steam').Strategy | |
passport.use new steamOID | |
returnURL: 'http://localhost:3000/auth/steam/return' | |
, realm: 'http://localhost:3000' | |
, () -> console.log arguments | |
passport.use new googOID | |
returnURL: 'http://localhost:3000/auth/goog/return' | |
, realm: 'http://localhost:3000' | |
, () -> console.log arguments | |
class App extends Tower.Application | |
@configure -> | |
@use "favicon", Tower.publicPath + "/favicon.png" | |
@use "static", Tower.publicPath, maxAge: Tower.publicCacheDuration | |
@use "profiler" if Tower.env != "production" | |
@use "logger" | |
@use "query" | |
@use "cookieParser", Tower.config.session.key | |
@use "session", secret: Tower.config.session.secret, cookie: {domain: Tower.config.session.cookie.domain} | |
@use "bodyParser", uploadDir: "./public/uploads" | |
#@use "csrf" | |
@use "methodOverride", "_method" | |
@use passport.initialize() | |
@use passport.session() | |
@use Tower.Middleware.Agent | |
@use Tower.Middleware.Location | |
#if Tower.httpCredentials && Tower.branch != "development" | |
# @use "basicAuth", Tower.httpCredentials.username, Tower.httpCredentials.password | |
@use Tower.Middleware.Router | |
module.exports = global.App = new App |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passport = require 'passport' | |
class App.ApplicationController extends Tower.Controller | |
@layout "application" | |
@beforeAction "bootstrap"#, only: "welcome" | |
welcome: -> | |
@render "welcome", locals: {@bootstrapData} | |
auth: -> | |
passport.authenticate(@params.provider) @request, @response, -> console.log arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tower.Route.draw -> | |
# @match "(/*path)", to: "application#index" | |
@match "/", to: "application#welcome" | |
@match '/auth/:provider', to: 'application#auth' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment