1
0
mirror of https://github.com/fazo96/homework.git synced 2025-01-09 12:10:08 +01:00

updated deps, added facebook support, bumped ver 1.2

This commit is contained in:
Enrico Fasoli 2015-03-02 15:55:29 +01:00
parent 50fff6b5e9
commit 91c9aac89d
10 changed files with 137 additions and 93 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
settings.json

View File

@ -16,3 +16,5 @@ kevohagan:sweetalert
accounts-twitter
fazo96:paginator
service-configuration
accounts-facebook

View File

@ -1 +1 @@
METEOR@1.0
METEOR@1.0.3.2

View File

@ -1,79 +1,80 @@
accounts-base@1.1.2
accounts-oauth@1.1.2
accounts-password@1.0.4
accounts-twitter@1.0.2
application-configuration@1.0.3
autoupdate@1.1.3
base64@1.0.1
binary-heap@1.0.1
blaze-tools@1.0.1
blaze@2.0.3
boilerplate-generator@1.0.1
callback-hook@1.0.1
check@1.0.2
coffeescript@1.0.4
ctl-helper@1.0.4
ctl@1.0.2
ddp@1.0.11
deps@1.0.5
ejson@1.0.4
email@1.0.4
fastclick@1.0.1
accounts-base@1.1.3
accounts-facebook@1.0.3
accounts-oauth@1.1.3
accounts-password@1.0.6
accounts-twitter@1.0.3
application-configuration@1.0.4
autoupdate@1.1.5
base64@1.0.2
binary-heap@1.0.2
blaze@2.0.4
blaze-tools@1.0.2
boilerplate-generator@1.0.2
callback-hook@1.0.2
check@1.0.4
coffeescript@1.0.5
ddp@1.0.14
deps@1.0.6
ejson@1.0.5
email@1.0.5
facebook@1.1.3
fastclick@1.0.2
fazo96:paginator@0.1.0
follower-livedata@1.0.2
geojson-utils@1.0.1
html-tools@1.0.2
htmljs@1.0.2
http@1.0.8
id-map@1.0.1
iron:controller@1.0.0
iron:core@1.0.0
iron:dynamic-template@1.0.0
iron:layout@1.0.0
iron:location@1.0.1
iron:middleware-stack@1.0.0
iron:router@1.0.1
iron:url@1.0.0
jquery@1.0.1
json@1.0.1
kevohagan:sweetalert@0.3.1
launch-screen@1.0.0
livedata@1.0.11
localstorage@1.0.1
logging@1.0.5
meteor-platform@1.2.0
meteor@1.1.3
minifiers@1.1.2
minimongo@1.0.5
mizzao:bootstrap-3@3.3.0
mobile-status-bar@1.0.1
mongo@1.0.8
follower-livedata@1.0.3
geojson-utils@1.0.2
html-tools@1.0.3
htmljs@1.0.3
http@1.0.10
id-map@1.0.2
iron:controller@1.0.7
iron:core@1.0.7
iron:dynamic-template@1.0.7
iron:layout@1.0.7
iron:location@1.0.7
iron:middleware-stack@1.0.7
iron:router@1.0.7
iron:url@1.0.7
jquery@1.11.3
json@1.0.2
kevohagan:sweetalert@0.4.2
launch-screen@1.0.1
livedata@1.0.12
localstorage@1.0.2
logging@1.0.6
meteor@1.1.4
meteor-platform@1.2.1
minifiers@1.1.3
minimongo@1.0.6
mizzao:bootstrap-3@3.3.1_1
mobile-status-bar@1.0.2
mongo@1.0.11
mrt:moment@2.8.1
natestrauser:font-awesome@4.2.0
natestrauser:font-awesome@4.3.0
npm-bcrypt@0.7.7
oauth1@1.1.2
oauth@1.1.2
observe-sequence@1.0.3
ordered-dict@1.0.1
random@1.0.1
reactive-dict@1.0.4
reactive-var@1.0.3
reload@1.1.1
retry@1.0.1
routepolicy@1.0.2
service-configuration@1.0.2
session@1.0.4
sha@1.0.1
spacebars-compiler@1.0.3
spacebars@1.0.3
spiderable@1.0.5
srp@1.0.1
standard-app-packages@1.0.3
templating@1.0.9
tracker@1.0.3
twitter@1.1.2
ui@1.0.4
underscore@1.0.1
url@1.0.2
webapp-hashing@1.0.1
webapp@1.1.4
oauth@1.1.3
oauth1@1.1.3
oauth2@1.1.2
observe-sequence@1.0.4
ordered-dict@1.0.2
random@1.0.2
reactive-dict@1.0.5
reactive-var@1.0.4
reload@1.1.2
retry@1.0.2
routepolicy@1.0.4
service-configuration@1.0.3
session@1.0.5
sha@1.0.2
spacebars@1.0.5
spacebars-compiler@1.0.4
spiderable@1.0.6
srp@1.0.2
standard-app-packages@1.0.4
templating@1.0.11
tracker@1.0.5
twitter@1.1.3
ui@1.0.5
underscore@1.0.2
url@1.0.3
webapp@1.1.6
webapp-hashing@1.0.2

View File

@ -44,7 +44,7 @@ Meteor.startup ->
### License
The MIT License (MIT)
Copyright (c) 2014 Enrico Fasoli
Copyright (c) 2014-2015 Enrico Fasoli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
# Homework - Client Side
version = "1.1.8"
version = "1.2"
# Utilities
tick = new Tracker.Dependency()
Meteor.setInterval (-> tick.changed();), 15000
@ -25,6 +25,10 @@ amIValid = ->
UI.registerHelper "version", -> version
UI.registerHelper "status", -> Meteor.status()
UI.registerHelper "loading", -> Meteor.loggingIn() or !Meteor.status().connected
UI.registerHelper "facebookAvailable", ->
Accounts.loginServicesConfigured() and ServiceConfiguration.configurations.find(service: "facebook").count() > 0
UI.registerHelper "twitterAvailable", ->
Accounts.loginServicesConfigured() and ServiceConfiguration.configurations.find(service: "twitter").count() > 0
UI.registerHelper "email", ->
if getUser()
if getUser().username then return getUser().username
@ -62,8 +66,8 @@ loggedInController = RouteController.extend
@render 'loading'
else @render()
onBeforeAction: ->
if not getUser() then Router.go 'home'
else if not amIValid() then Router.go 'verifyEmail'
if not getUser() then Router.redirect 'home'
else if not amIValid() then Router.redirect 'verifyEmail'
@next()
guestController = RouteController.extend
@ -73,7 +77,7 @@ guestController = RouteController.extend
else @render()
onBeforeAction: ->
if getUser()
if amIValid() is no then Router.go 'verifyEmail' else Router.go 'notes'
if amIValid() is no then Router.redirect 'verifyEmail' else Router.redirect 'notes'
@next()
# Page Routing
@ -84,7 +88,7 @@ Router.route '/',
onBeforeAction: ->
# Dispatch user to the right landing page based on his account status
if getUser()
if amIValid() is yes then Router.go 'notes' else Router.go 'verifyEmail'
if amIValid() is yes then Router.redirect 'notes' else Router.redirect 'verifyEmail'
@next()
Router.route '/login', controller: guestController
Router.route '/register', controller: guestController
@ -104,7 +108,8 @@ Router.route '/verify/:token?',
onBeforeAction: ->
if getUser()
if amIValid()
Router.go 'home'; @next()
Router.redirect 'home'
@next()
else if @params.token? and @params.token isnt ""
# Automatic verification
@render 'loading'
@ -116,7 +121,8 @@ Router.route '/verify/:token?',
Router.go 'home'
@next()
else
Router.go 'home'; @next()
Router.redirect 'home'
@next()
Router.route '/archive/:_id?',
name: 'archive'
waitOn: -> @notes = Meteor.subscribe 'notes', yes
@ -132,14 +138,18 @@ logoutCallback = (err) ->
errCallback = (err) ->
if err.reason
showError msg: err.reason
else showErrror msg: err
else showError msg: err
loginCallback = (e) ->
if e? then errCallback e
else
Router.go 'notes'
swal 'Ok', 'Logged In', 'success'
Template.homepage.events
'click #twitter': -> Meteor.loginWithTwitter (e) ->
if e? then errCallback e
else
Router.go 'notes'
swal 'Ok', 'Logged In', 'success'
'click #facebook': -> Meteor.loginWithFacebook loginCallback
'click #twitter': -> Meteor.loginWithTwitter loginCallback
Template.reconnect.helpers
time : ->
tick.depend()

View File

@ -5,7 +5,7 @@ input {
max-width: 400px;
}
#twitter {
#twitter, #facebook {
margin-bottom: 1em;
}

View File

@ -272,9 +272,16 @@
</div>
{{#unless loading}}
<div align="center" style="margin-top:20px;">
{{#if twitterAvailable}}
<a id="twitter" class="btn btn-primary">
<i class="fa fa-twitter"></i> Log In with Twitter
</a><br>
{{/if}}
{{#if facebookAvailable}}
<a id="facebook" class="btn btn-primary">
<i class="fa fa-facebook"></i> Log In with Facebook
</a><br>
{{/if}}
<a href="{{pathFor 'login'}}" role="button" class="btn btn-primary">
<i class="fa fa-sign-in"></i> Sign In
</a>

View File

@ -10,11 +10,34 @@ Accounts.config {
loginExpirationInDays: 30
}
# Login via external services
if Meteor.settings.facebook
ServiceConfiguration.configurations.upsert { service: "facebook" }, $set: {
service: "facebook"
appId: Meteor.settings.facebook.appId
#loginStyle: "popup"
secret: Meteor.settings.facebook.secret
}
else ServiceConfiguration.configurations.remove { service: "facebook" }
if Meteor.settings.twitter
ServiceConfiguration.configurations.upsert { service: "twitter" }, $set: {
service: "twitter"
consumerKey: Meteor.settings.twitter.consumerKey
#loginStyle: "popup"
secret: Meteor.settings.twitter.secret
}
else ServiceConfiguration.configurations.remove { service: "twitter" }
# Code that checks if a new user request is valid
Accounts.validateNewUser (user) ->
if user.services.twitter?
user.username = user.services.twitter.screenName
return yes
if user.services.facebook?
user.username = user.services.facebook.name
return yes
mail = user.emails[0].address
if Match.test(mail,String) is no or validateEmail(mail) is no
throw new Meteor.Error 403, "Invalid Email"

View File

@ -13,7 +13,7 @@ isUsers = (u,doc) -> u and doc.userId is u
# Returns true if the user has verified at least one email address
userValidated = (user) ->
return no unless user?
return yes if user.services.twitter
return yes if user.services.twitter or user.services.facebook
return yes for mail in user.emails when mail.verified is yes; no
Meteor.publish 'user', ->