Skip to content

Commit

Permalink
Dolphin package for Rocket.Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTr committed Jan 7, 2016
1 parent 9a1e394 commit 716df55
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 7 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Expand Up @@ -44,6 +44,7 @@ rocketchat:channel-settings
rocketchat:channel-settings-mail-messages
rocketchat:colors
rocketchat:custom-oauth
rocketchat:dolphin
rocketchat:emojione
rocketchat:favico
rocketchat:file
Expand Down
1 change: 1 addition & 0 deletions .meteor/versions
Expand Up @@ -129,6 +129,7 @@ rocketchat:channel-settings-mail-messages@0.0.1
rocketchat:colors@0.0.1
rocketchat:cors@0.0.1
rocketchat:custom-oauth@1.0.0
rocketchat:dolphin@0.0.1
rocketchat:emojione@0.0.1
rocketchat:favico@0.0.1
rocketchat:file@0.0.1
Expand Down
26 changes: 26 additions & 0 deletions packages/rocketchat-dolphin/common.coffee
@@ -0,0 +1,26 @@
config =
serverURL: ''
authorizePath: '/m/oauth2/auth/'
tokenPath: '/m/oauth2/token/'
identityPath: '/m/oauth2/api/me/'
addAutopublishFields:
forLoggedInUser: ['services.dolphin']
forOtherUsers: ['services.dolphin.name']

Dolphin = new CustomOAuth 'dolphin', config

if Meteor.isServer
Meteor.startup ->
RocketChat.models.Settings.find({ _id: 'API_Dolphin_URL' }).observe
added: (record) ->
config.serverURL = RocketChat.settings.get 'API_Dolphin_URL'
Dolphin.configure config
changed: (record) ->
config.serverURL = RocketChat.settings.get 'API_Dolphin_URL'
Dolphin.configure config
else
Meteor.startup ->
Tracker.autorun ->
if RocketChat.settings.get 'API_Dolphin_URL'
config.serverURL = RocketChat.settings.get 'API_Dolphin_URL'
Dolphin.configure config
6 changes: 6 additions & 0 deletions packages/rocketchat-dolphin/i18n/de.i18n.json
@@ -0,0 +1,6 @@
{
"API_Dolphin_URL" : "Dolphin URL",
"Accounts_OAuth_Dolphin" : "Dolphin Login",
"Accounts_OAuth_Dolphin_id" : "Dolphin Key",
"Accounts_OAuth_Dolphin_secret" : "Dolphin Secret"
}
6 changes: 6 additions & 0 deletions packages/rocketchat-dolphin/i18n/en.i18n.json
@@ -0,0 +1,6 @@
{
"API_Dolphin_URL" : "Dolphin URL",
"Accounts_OAuth_Dolphin" : "Dolphin Login",
"Accounts_OAuth_Dolphin_id" : "Dolphin Key",
"Accounts_OAuth_Dolphin_secret" : "Dolphin Secret"
}
6 changes: 6 additions & 0 deletions packages/rocketchat-dolphin/i18n/fi.i18n.json
@@ -0,0 +1,6 @@
{
"API_Dolphin_URL" : "Dolphin URL",
"Accounts_OAuth_Dolphin" : "Dolphin-kirjautuminen",
"Accounts_OAuth_Dolphin_id" : "Dolphin Key",
"Accounts_OAuth_Dolphin_secret" : "Dolphin Secret"
}
6 changes: 6 additions & 0 deletions packages/rocketchat-dolphin/i18n/ko.i18n.json
@@ -0,0 +1,6 @@
{
"API_Dolphin_URL" : "Dolphin URL",
"Accounts_OAuth_Dolphin" : "Dolphin 로그인",
"Accounts_OAuth_Dolphin_id" : "Dolphin Key",
"Accounts_OAuth_Dolphin_secret" : "Dolphin 암호"
}
6 changes: 6 additions & 0 deletions packages/rocketchat-dolphin/i18n/ro.i18n.json
@@ -0,0 +1,6 @@
{
"API_Dolphin_URL" : "URL Dolphin",
"Accounts_OAuth_Dolphin" : "Autentificare Dolphin",
"Accounts_OAuth_Dolphin_id" : " Key Dolphin",
"Accounts_OAuth_Dolphin_secret" : "Secret Dolphin"
}
6 changes: 6 additions & 0 deletions packages/rocketchat-dolphin/i18n/ru.i18n.json
@@ -0,0 +1,6 @@
{
"API_Dolphin_URL" : "Адрес Dolphin сайта",
"Accounts_OAuth_Dolphin" : "Dolphin Соединение",
"Accounts_OAuth_Dolphin_id" : "Dolphin Key",
"Accounts_OAuth_Dolphin_secret" : "Dolphin Secret"
}
7 changes: 7 additions & 0 deletions packages/rocketchat-dolphin/login-button.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions packages/rocketchat-dolphin/package.js
@@ -0,0 +1,32 @@
Package.describe({
name: 'rocketchat:dolphin',
version: '0.0.1',
summary: 'RocketChat settings for Dolphin Oauth'
});

Package.onUse(function(api) {
api.versionsFrom('1.0');
api.use('coffeescript');
api.use('rocketchat:lib@0.0.1');
api.use('rocketchat:custom-oauth');
api.addFiles("common.coffee");
api.addFiles('login-button.css', 'client');
api.addFiles('startup.coffee', 'server');

// TAPi18n
api.use('templating', 'client');
var _ = Npm.require('underscore');
var fs = Npm.require('fs');
tapi18nFiles = _.compact(_.map(fs.readdirSync('packages/rocketchat-dolphin/i18n'), function(filename) {
if (fs.statSync('packages/rocketchat-dolphin/i18n/' + filename).size > 16) {
return 'i18n/' + filename;
}
}));
api.use('tap:i18n@1.6.1', ['client', 'server']);
api.imply('tap:i18n');
api.addFiles(tapi18nFiles, ['client', 'server']);
});

Package.onTest(function(api) {

});
5 changes: 5 additions & 0 deletions packages/rocketchat-dolphin/startup.coffee
@@ -0,0 +1,5 @@
RocketChat.settings.add 'API_Dolphin_URL', '', { type: 'string', group: 'Accounts', public: true, section: 'Dolphin' }
RocketChat.settings.add 'Accounts_OAuth_Dolphin', false, { type: 'boolean', group: 'Accounts', section: 'Dolphin' }
RocketChat.settings.add 'Accounts_OAuth_Dolphin_id', '', { type: 'string', group: 'Accounts', section: 'Dolphin' }
RocketChat.settings.add 'Accounts_OAuth_Dolphin_secret', '', { type: 'string', group: 'Accounts', section: 'Dolphin' }

14 changes: 7 additions & 7 deletions packages/rocketchat-lib/server/startup/settings.coffee
Expand Up @@ -5,21 +5,21 @@ if not RocketChat.models.Settings.findOneById 'uniqueID'
RocketChat.settings.addGroup 'Accounts', ->
@add 'Accounts_AllowUserProfileChange', true, { type: 'boolean', public: true }
@add 'Accounts_AllowUserAvatarChange', true, { type: 'boolean', public: true }
@add 'Accounts_AllowUsernameChange', true, { type: 'boolean', public: true }
@add 'Accounts_AllowPasswordChange', true, { type: 'boolean', public: true }
@add 'Accounts_RequireNameForSignUp', true, { type: 'boolean', public: true }
@add 'Accounts_AllowUsernameChange', false, { type: 'boolean', public: true }
@add 'Accounts_AllowPasswordChange', false, { type: 'boolean', public: true }
@add 'Accounts_RequireNameForSignUp', false, { type: 'boolean', public: true }
@add 'Accounts_LoginExpiration', 90, { type: 'int', public: true }
@add 'Accounts_ShowFormLogin', true, { type: 'boolean', public: true }

@section 'Registration', ->
@add 'Accounts_EmailVerification', false, { type: 'boolean', public: true }
@add 'Accounts_ManuallyApproveNewUsers', false, { type: 'boolean' }
@add 'Accounts_AllowedDomainsList', '', { type: 'string', public: true }
@add 'Accounts_RegistrationForm', 'Public', { type: 'select', public: true, values: [ { key: 'Public', i18nLabel: 'Accounts_RegistrationForm_Public' }, { key: 'Disabled', i18nLabel: 'Accounts_RegistrationForm_Disabled' }, { key: 'Secret URL', i18nLabel: 'Accounts_RegistrationForm_Secret_URL' } ] }
@add 'Accounts_RegistrationForm', 'Disabled', { type: 'select', public: true, values: [ { key: 'Public', i18nLabel: 'Accounts_RegistrationForm_Public' }, { key: 'Disabled', i18nLabel: 'Accounts_RegistrationForm_Disabled' }, { key: 'Secret URL', i18nLabel: 'Accounts_RegistrationForm_Secret_URL' } ] }
@add 'Accounts_RegistrationForm_SecretURL', Random.id(), { type: 'string' }
@add 'Accounts_RegistrationForm_LinkReplacementText', 'New user registration is currently disabled', { type: 'string', public: true }
@add 'Accounts_Registration_AuthenticationServices_Enabled', true, { type: 'boolean', public: true }
@add 'Accounts_PasswordReset', true, { type: 'boolean', public: true }
@add 'Accounts_PasswordReset', false, { type: 'boolean', public: true }

@section 'Avatar', ->
@add 'Accounts_AvatarResize', true, { type: 'boolean' }
Expand Down Expand Up @@ -147,7 +147,7 @@ RocketChat.settings.addGroup 'Push', ->


RocketChat.settings.addGroup 'Layout', ->
@add 'Layout_Sidenav_Footer', '<div><a href="https://github.com/RocketChat/Rocket.Chat" class="logo" target="_blank"> <img src="/images/logo/logo.svg?v=3" /></a><div class="github-tagline"><span class="octicon octicon-pencil" style="color: #994C00"></span> with <span class="octicon octicon-heart" style="color: red"></span> on <span class="octicon octicon-mark-github"></span></div></div>', { type: 'string', public: true, i18nDescription: 'Layout_Sidenav_Footer_description' }
@add 'Layout_Sidenav_Footer', '', { type: 'string', public: true, i18nDescription: 'Layout_Sidenav_Footer_description' }

@section 'Content', ->
@add 'Layout_Home_Title', 'Home', { type: 'string', public: true }
Expand All @@ -157,7 +157,7 @@ RocketChat.settings.addGroup 'Layout', ->

@section 'Login', ->
@add 'Layout_Login_Header', '<a class="logo" href="/"><img src="/images/logo/logo.svg?v=3" /></a>', { type: 'string', multiline: true, public: true }
@add 'Layout_Login_Terms', 'By proceeding to create your account and use Rocket.Chat, you are agreeing to our <a href="/terms-of-service">Terms of Service</a> and <a href="/privacy-policy">Privacy Policy</a>. If you do not agree, you cannot use Rocket.Chat.', { type: 'string', multiline: true, public: true }
@add 'Layout_Login_Terms', '', { type: 'string', multiline: true, public: true }


RocketChat.settings.add 'Statistics_opt_out', false, { type: 'boolean', group: false }
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-ui-account/account/avatar/prompt.html
Expand Up @@ -71,6 +71,7 @@ <h2>
{{#if suggestions.ready}}
{{> avatarSuggestion suggestions.avatars.gravatar}}
{{> avatarSuggestion suggestions.avatars.facebook}}
{{> avatarSuggestion suggestions.avatars.dolphin}}
{{> avatarSuggestion suggestions.avatars.google}}
{{> avatarSuggestion suggestions.avatars.github}}
{{> avatarSuggestion suggestions.avatars.gitlab}}
Expand All @@ -80,6 +81,9 @@ <h2>
{{#if suggestAvatar 'facebook'}}
{{> avatarSuggestionLogin 'facebook'}}
{{/if}}
{{#if suggestAvatar 'dolphin'}}
{{> avatarSuggestionLogin 'dolphin'}}
{{/if}}
{{#if suggestAvatar 'google'}}
{{> avatarSuggestionLogin 'google'}}
{{/if}}
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui-flextab/flex-tab/tabs/userInfo.html
Expand Up @@ -15,6 +15,7 @@ <h3 title="{{username}}"><i class="status-{{status}}"></i> {{username}}</h3>
{{#if lastLogin}} <p><i class="icon-calendar"></i> {{_ "Created_at"}}: {{createdAt}}</p> {{/if}}
{{#if lastLogin}} <p><i class="icon-calendar"></i> {{_ "Last_login"}}: {{lastLogin}}</p> {{/if}}
{{#if services.facebook.id}} <p><i class="icon-facebook"></i><a href="{{services.facebook.link}}" target="_blank">{{services.facebook.name}}</a></p> {{/if}}
{{#if services.dolphin.id}} <p><i class="icon-user"></i><a href="{{services.dolphin.profile_link}}" target="_blank">{{services.dolphin.profile_display_name}}</a></p> {{/if}}
{{#if services.github.id}} <p><i class="icon-github-circled"></i><a href="https://www.github.com/{{services.github.username}}" target="_blank">{{services.github.username}}</a></p> {{/if}}
{{#if services.gitlab.id}} <p><i class="icon-gitlab"></i>{{services.gitlab.username}}</p> {{/if}}
{{#if services.google.id}} <p><i class="icon-gplus"></i><a href="https://plus.google.com/{{services.google.id}}" target="_blank">{{services.google.name}}</a></p> {{/if}}
Expand Down
5 changes: 5 additions & 0 deletions server/methods/getAvatarSuggestion.coffee
Expand Up @@ -6,6 +6,11 @@
service: 'facebook'
url: "https://graph.facebook.com/#{user.services.facebook.id}/picture?type=large"

if user.services.dolphin?.id? and RocketChat.settings.get 'Accounts_OAuth_Dolphin'
avatars.push
service: 'dolphin'
url: user.services.dolphin.picture

if user.services.google?.picture? and user.services.google.picture isnt "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg" and RocketChat.settings.get 'Accounts_OAuth_Google'
avatars.push
service: 'google'
Expand Down
2 changes: 2 additions & 0 deletions server/startup/initialData.coffee
Expand Up @@ -39,6 +39,8 @@ Meteor.startup ->
verified: true
],
name: 'Admin'
username: 'Admin',
active: 1

Accounts.setPassword id, process.env.ADMIN_PASS
RocketChat.authz.addUsersToRoles( id, 'admin')
Expand Down

0 comments on commit 716df55

Please sign in to comment.