mirror of
https://github.com/fazo96/markcloud.git
synced 2025-01-26 13:34:19 +01:00
added twitter auth
This commit is contained in:
parent
f276c97deb
commit
ce757fedbf
@ -14,4 +14,5 @@ accounts-password
|
|||||||
mrt:moment
|
mrt:moment
|
||||||
reactive-var
|
reactive-var
|
||||||
kevohagan:sweetalert
|
kevohagan:sweetalert
|
||||||
|
accounts-twitter
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
accounts-base@1.1.1
|
accounts-base@1.1.1
|
||||||
|
accounts-oauth@1.1.1
|
||||||
accounts-password@1.0.2
|
accounts-password@1.0.2
|
||||||
|
accounts-twitter@1.0.1
|
||||||
application-configuration@1.0.2
|
application-configuration@1.0.2
|
||||||
autoupdate@1.1.1
|
autoupdate@1.1.1
|
||||||
base64@1.0.0
|
base64@1.0.0
|
||||||
@ -44,6 +46,8 @@ mongo@1.0.6
|
|||||||
mrt:moment@2.8.1
|
mrt:moment@2.8.1
|
||||||
natestrauser:font-awesome@4.2.0
|
natestrauser:font-awesome@4.2.0
|
||||||
npm-bcrypt@0.7.7
|
npm-bcrypt@0.7.7
|
||||||
|
oauth1@1.1.0
|
||||||
|
oauth@1.1.0
|
||||||
observe-sequence@1.0.2
|
observe-sequence@1.0.2
|
||||||
ordered-dict@1.0.0
|
ordered-dict@1.0.0
|
||||||
perak:markdown@1.0.4
|
perak:markdown@1.0.4
|
||||||
@ -61,6 +65,7 @@ spacebars@1.0.2
|
|||||||
srp@1.0.0
|
srp@1.0.0
|
||||||
templating@1.0.7
|
templating@1.0.7
|
||||||
tracker@1.0.2
|
tracker@1.0.2
|
||||||
|
twitter@1.1.0
|
||||||
ui@1.0.3
|
ui@1.0.3
|
||||||
underscore@1.0.0
|
underscore@1.0.0
|
||||||
url@1.0.0
|
url@1.0.0
|
||||||
|
16
README.md
16
README.md
@ -14,6 +14,22 @@ If you want to set up a server, make sure to configure the `MAIL_URL`
|
|||||||
and `ROOT_URL` environment variables as explained in the
|
and `ROOT_URL` environment variables as explained in the
|
||||||
[Meteor Docs](http://docs.meteor.com).
|
[Meteor Docs](http://docs.meteor.com).
|
||||||
|
|
||||||
|
#### Twitter Authentication
|
||||||
|
|
||||||
|
Create this file: `server/settings.coffee` with this content:
|
||||||
|
|
||||||
|
```coffeescript
|
||||||
|
Meteor.startup ->
|
||||||
|
Accounts.loginServiceConfiguration.remove service : 'twitter'
|
||||||
|
Accounts.loginServiceConfiguration.insert
|
||||||
|
service: 'twitter'
|
||||||
|
consumerKey: 'Your API key'
|
||||||
|
secret: 'Your API secret'
|
||||||
|
```
|
||||||
|
|
||||||
|
Your users will now be able to login using twitter. You may want to disable the
|
||||||
|
button if you don't configure twitter authentication.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
@ -2,9 +2,11 @@ docs = new Meteor.Collection 'docs'
|
|||||||
|
|
||||||
amIValid = ->
|
amIValid = ->
|
||||||
return no unless Meteor.user()
|
return no unless Meteor.user()
|
||||||
|
return yes if !Meteor.user().emails?
|
||||||
return yes for mail in Meteor.user().emails when mail.verified is yes; no
|
return yes for mail in Meteor.user().emails when mail.verified is yes; no
|
||||||
|
|
||||||
UI.registerHelper 'mail', -> Meteor.user().emails[0].address
|
UI.registerHelper 'mail', ->
|
||||||
|
if Meter.user().emails then Meteor.user().emails[0].address
|
||||||
UI.registerHelper 'amIValid', amIValid
|
UI.registerHelper 'amIValid', amIValid
|
||||||
|
|
||||||
Router.configure
|
Router.configure
|
||||||
@ -17,7 +19,6 @@ docController = RouteController.extend
|
|||||||
waitOn: -> Meteor.subscribe 'doc', @params._id
|
waitOn: -> Meteor.subscribe 'doc', @params._id
|
||||||
data: -> docs.findOne @params._id
|
data: -> docs.findOne @params._id
|
||||||
action: ->
|
action: ->
|
||||||
console.log @render
|
|
||||||
if @ready()
|
if @ready()
|
||||||
if @data()? then @render()
|
if @data()? then @render()
|
||||||
else @render '404'
|
else @render '404'
|
||||||
@ -85,14 +86,20 @@ share.notify = notify = (opt) ->
|
|||||||
|
|
||||||
errCallback = (err) ->
|
errCallback = (err) ->
|
||||||
return unless err
|
return unless err
|
||||||
console.log err
|
|
||||||
if err.reason
|
if err.reason
|
||||||
notify title: err.code or 'Error', msg: err.reason, type: 'error'
|
notify title: err.code or 'Error', msg: err.reason, type: 'error'
|
||||||
else notify title: 'Error', msg: err, type: 'error'
|
else notify title: 'Error', msg: err, type: 'error'
|
||||||
|
|
||||||
Template.layout.notHome = -> Router.current().route.name isnt 'home'
|
Template.layout.notHome = -> Router.current().route.name isnt 'home'
|
||||||
Template.layout.showSpinner = ->
|
Template.layout.showSpinner = -> Meteor.status().connected is yes
|
||||||
Meteor.status().connected is no or Router.current().ready() is no
|
Template.home.events
|
||||||
|
'click #twitter-login': ->
|
||||||
|
if Meteor.user() then return notify msg: "You're already Logged In!"
|
||||||
|
Meteor.loginWithTwitter {}, (e) ->
|
||||||
|
if e then errCallback e
|
||||||
|
else
|
||||||
|
Meteor.subscribe 'user'
|
||||||
|
notify type: 'success', msg: 'Logged in'
|
||||||
Template.editor.isPublic = -> return "checked" if @public is yes
|
Template.editor.isPublic = -> return "checked" if @public is yes
|
||||||
Template.editor.showTitleChecked = -> return "checked" unless @showTitle is no
|
Template.editor.showTitleChecked = -> return "checked" unless @showTitle is no
|
||||||
Template.editor.events
|
Template.editor.events
|
||||||
|
@ -74,6 +74,9 @@
|
|||||||
#profile-tools {
|
#profile-tools {
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
|
a {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
|
@ -50,9 +50,7 @@
|
|||||||
{{#markdown}}
|
{{#markdown}}
|
||||||
### Share your markdown easily
|
### Share your markdown easily
|
||||||
|
|
||||||
Markcloud is a simple application that lets you share your markdown documents
|
Markcloud is a simple application that lets you share your markdown documents to the world. Just paste your markdown and get a _permanent link_ that lets you and everyone else view the result in a **modern responsive web page**.
|
||||||
to the world. Just paste your markdown and get a _permanent link_ that lets you
|
|
||||||
and everyone else view the result in a **modern responsive web page**.
|
|
||||||
|
|
||||||
### Free as in Free Software
|
### Free as in Free Software
|
||||||
|
|
||||||
@ -77,10 +75,14 @@ This home page is written in markdown too!
|
|||||||
You will be able to delete your account and all your data whenever you want.
|
You will be able to delete your account and all your data whenever you want.
|
||||||
{{/markdown}}
|
{{/markdown}}
|
||||||
<div class="text-center" id="btns">
|
<div class="text-center" id="btns">
|
||||||
|
<a class="btn btn-primary" id="twitter-login">
|
||||||
|
<i class="fa fa-twitter"></i> Log In With Twitter</a>
|
||||||
|
<br>or<br>
|
||||||
<a class="btn btn-primary" href="/signup">
|
<a class="btn btn-primary" href="/signup">
|
||||||
<i class="fa fa-user"></i> Sign Up</a>
|
<i class="fa fa-user"></i> Sign Up</a>
|
||||||
<a class="btn btn-success" href="/login">
|
<a class="btn btn-success" href="/login">
|
||||||
<i class="fa fa-sign-in"></i> Log In</a>
|
<i class="fa fa-sign-in"></i> Log In</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -187,7 +189,11 @@ You will be able to delete your account and all your data whenever you want.
|
|||||||
<template name="profile">
|
<template name="profile">
|
||||||
{{#if isMe}}
|
{{#if isMe}}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
|
{{#if mail}}
|
||||||
<p>Hello <b>{{username}}</b> ({{mail}}). This is your profile.</p>
|
<p>Hello <b>{{username}}</b> ({{mail}}). This is your profile.</p>
|
||||||
|
{{else}}
|
||||||
|
<p>Hello <b>{{profile.name}}</b> (@{{username}}). This is your profile.</p>
|
||||||
|
{{/if}}
|
||||||
{{#if noDocs}}
|
{{#if noDocs}}
|
||||||
<p>You don't have any documents yet.</p>
|
<p>You don't have any documents yet.</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@ -210,9 +216,9 @@ You will be able to delete your account and all your data whenever you want.
|
|||||||
{{else}}
|
{{else}}
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
{{#if noDocs}}
|
{{#if noDocs}}
|
||||||
<p>{{username}} doesn't have any public documents.</p>
|
<p>@{{username}} doesn't have any public documents.</p>
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>These are {{username}}'s public documents.</p>
|
<p>These are @{{username}}'s public documents.</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
1
server/.gitignore
vendored
Normal file
1
server/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
settings.coffee
|
@ -13,6 +13,9 @@ Accounts.config {
|
|||||||
# Code that checks if a new user request is valid
|
# Code that checks if a new user request is valid
|
||||||
Accounts.validateNewUser (user) ->
|
Accounts.validateNewUser (user) ->
|
||||||
user.dateCreated = moment().unix()
|
user.dateCreated = moment().unix()
|
||||||
|
if user.services.twitter?
|
||||||
|
user.username = user.services.twitter.screenName
|
||||||
|
return yes
|
||||||
mail = user.emails[0].address
|
mail = user.emails[0].address
|
||||||
if Match.test(mail,String) is no or validateEmail(mail) is no
|
if Match.test(mail,String) is no or validateEmail(mail) is no
|
||||||
throw new Meteor.Error 403, "Invalid Email"
|
throw new Meteor.Error 403, "Invalid Email"
|
||||||
|
@ -16,6 +16,7 @@ Meteor.startup ->
|
|||||||
validatedUser = (uid) ->
|
validatedUser = (uid) ->
|
||||||
u = Meteor.users.findOne uid
|
u = Meteor.users.findOne uid
|
||||||
return no unless u
|
return no unless u
|
||||||
|
return yes if u.services.twitter
|
||||||
return yes for mail in u.emails when mail.verified is yes; no
|
return yes for mail in u.emails when mail.verified is yes; no
|
||||||
|
|
||||||
Meteor.publish 'doc', (id) -> docs.find {_id: id}, limit: 1
|
Meteor.publish 'doc', (id) -> docs.find {_id: id}, limit: 1
|
||||||
@ -26,9 +27,10 @@ Meteor.publish 'docs', (userId) ->
|
|||||||
else docs.find {owner: userId, public: yes}, fields: text: 0
|
else docs.find {owner: userId, public: yes}, fields: text: 0
|
||||||
else docs.find {}, fields: text: 0
|
else docs.find {}, fields: text: 0
|
||||||
Meteor.publish 'user', (id) ->
|
Meteor.publish 'user', (id) ->
|
||||||
|
id ?= @userId
|
||||||
if @userId is id
|
if @userId is id
|
||||||
Meteor.users.find id, fields: {username: 1, emails: 1}
|
Meteor.users.find id, fields: { username: 1, emails: 1, profile: 1 }
|
||||||
else Meteor.users.find id, fields: {username: 1}
|
else Meteor.users.find id, fields: { username : 1, profile: 1 }
|
||||||
|
|
||||||
docs.allow
|
docs.allow
|
||||||
insert: (uid,doc) ->
|
insert: (uid,doc) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user