Skip to content

Commit

Permalink
Secret URL - Fixes #1574
Browse files Browse the repository at this point in the history
  • Loading branch information
marceloschmidt committed Dec 4, 2015
1 parent 13df770 commit 527ffac
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
22 changes: 12 additions & 10 deletions client/routes/router.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ FlowRouter.route '/fxos',
FlowRouter.route '/register/:hash',
name: 'register-secret-url'
action: (params) ->
if RocketChat.settings.get('Accounts_RegistrationForm') is 'Secret URL'
Meteor.call 'checkRegistrationSecretURL', params.hash, (err, success) ->
if success
Session.set 'loginDefaultState', 'register'
BlazeLayout.render 'main', {center: 'home'}
KonchatNotification.getDesktopPermission()
else
BlazeLayout.render 'blankLayout', { render: 'invalidSecretURL' }
else
BlazeLayout.render 'blankLayout', { render: 'invalidSecretURL' }
BlazeLayout.render 'secretURL'

# if RocketChat.settings.get('Accounts_RegistrationForm') is 'Secret URL'
# Meteor.call 'checkRegistrationSecretURL', params.hash, (err, success) ->
# if success
# Session.set 'loginDefaultState', 'register'
# BlazeLayout.render 'main', {center: 'home'}
# KonchatNotification.getDesktopPermission()
# else
# BlazeLayout.render 'logoLayout', { render: 'invalidSecretURL' }
# else
# BlazeLayout.render 'logoLayout', { render: 'invalidSecretURL' }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template name="blankLayout">
<template name="logoLayout">
<section class="full-page">
<div class="wrapper">
<header>
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui-master/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Package.onUse(function(api) {
api.addFiles('master/main.html', 'client');
api.addFiles('master/loading.html', 'client');
api.addFiles('master/error.html', 'client');
api.addFiles('master/blankLayout.html', 'client');
api.addFiles('master/logoLayout.html', 'client');

api.addFiles('master/main.coffee', 'client');
});
2 changes: 2 additions & 0 deletions packages/rocketchat-ui/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Package.onUse(function(api) {
api.addFiles('views/app/privateHistory.html', 'client');
api.addFiles('views/app/room.html', 'client');
api.addFiles('views/app/roomSearch.html', 'client');
api.addFiles('views/app/secretURL.html', 'client');
api.addFiles('views/app/userSearch.html', 'client');
api.addFiles('views/app/spotlight/mobileMessageMenu.html', 'client');
api.addFiles('views/app/spotlight/spotlight.html', 'client');
Expand All @@ -97,6 +98,7 @@ Package.onUse(function(api) {
api.addFiles('views/app/privateHistory.coffee', 'client');
api.addFiles('views/app/room.coffee', 'client');
api.addFiles('views/app/roomSearch.coffee', 'client');
api.addFiles('views/app/secretURL.coffee', 'client');
api.addFiles('views/app/spotlight/mobileMessageMenu.coffee', 'client');
api.addFiles('views/app/spotlight/spotlight.coffee', 'client');
api.addFiles('views/app/videoCall/videoButtons.coffee', 'client');
Expand Down
21 changes: 21 additions & 0 deletions packages/rocketchat-ui/views/app/secretURL.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Template.secretURL.helpers
registrationAllowed: ->
return RocketChat.settings.get('Accounts_RegistrationForm') is 'Secret URL' and Template.instance().hashIsValid?.get()

ready: ->
return Template.instance().subscriptionsReady?() and Template.instance().hashReady?.get()


Template.secretURL.onCreated ->
@subscribe 'admin-settings'
@hashIsValid = new ReactiveVar false
@hashReady = new ReactiveVar false

Meteor.call 'checkRegistrationSecretURL', FlowRouter.getParam('hash'), (err, success) =>
@hashReady.set true
if success
Session.set 'loginDefaultState', 'register'
KonchatNotification.getDesktopPermission()
@hashIsValid.set true
else
@hashIsValid.set false
11 changes: 11 additions & 0 deletions packages/rocketchat-ui/views/app/secretURL.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template name="secretURL">
{{#if ready}}
{{#if registrationAllowed}}
{{> main center="home"}}
{{else}}
{{> logoLayout render="invalidSecretURL"}}
{{/if}}
{{else}}
{{> loading}}
{{/if}}
</template>

0 comments on commit 527ffac

Please sign in to comment.