Skip to content

Commit

Permalink
Merge pull request #78 from reactioncommerce/guest-checkout-updates
Browse files Browse the repository at this point in the history
Guest checkout updates
  • Loading branch information
Aaron Judd committed Jan 23, 2015
2 parents 7f36b45 + 7515376 commit 6241d69
Show file tree
Hide file tree
Showing 171 changed files with 3,110 additions and 16,114 deletions.
8 changes: 7 additions & 1 deletion packages/reaction-core/client/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ _.extend ReactionCore,
isMember: false
isOwner: null
isAdmin: null
canCheckoutAsGuest: false
userPermissions: []
shopPermissions: []
shopPermissionGroups: []
Expand All @@ -18,6 +19,8 @@ _.extend ReactionCore,

if shop
self.shopId = shop._id
# check to see if guest checkout is enabled
self.canCheckoutAsGuest = shop.canCheckoutAsGuest || false
#permissions and packages
permissions = []
# package registry update
Expand Down Expand Up @@ -59,15 +62,18 @@ _.extend ReactionCore,
self.userPermissions = []
self.shopPermissions = []
self.shopPermissionGroups = []

# dashboard access
hasDashboardAccess: ->
return @isMember or @.hasOwnerAccess()
# permission check
hasPermission: (permissions) ->
return false unless permissions
permissions = [permissions] unless _.isArray(permissions)
return @.hasOwnerAccess() or _.intersection(permissions, @userPermissions).length or (@isAdmin and _.intersection(permissions, @shopPermissions).length)
# role checkout
hasOwnerAccess: ->
return Roles.userIsInRole(Meteor.user(), "admin") or @isOwner
# returns shop id
getShopId: ->
return @shopId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ Template._loginButtonsLoggedOutPasswordService.helpers
loginButtonsSession.set 'inForgotPasswordFlow', false

canCheckoutAsGuest: ->
!!ReactionCore.canCheckoutAsGuest()
!!ReactionCore.canCheckoutAsGuest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{{#if dropdownVisible}}
<div id="login-dropdown-list" class="accounts-dialog">
<a class="login-close-text" data-i18n="accountsUI.close">Close</a>
<a class="login-close-text" data-i18n="app.close">Close</a>
<div class="login-close-text-clear"></div>

{{#if inMessageOnlyFlow}}
Expand All @@ -28,7 +28,7 @@

<template name="core_loginButtonsLoggedInDropdownActions">
{{#if allowChangingPassword}}
<div class="login-button" id="login-buttons-open-change-password">
<div class="login-button" id="login-buttons-open-change-password" data-18n="accountUI.changePassword">
Change password
</div>
{{/if}}
Expand All @@ -50,7 +50,7 @@
makes the position of "Close" match the position of this text. }}
<a class="login-link-text" id="login-sign-in-link"><span data-i18n="accountsUI.signIn">Sign in</span></a>
<div id="login-dropdown-list" class="accounts-dialog">
<a class="login-close-text">Close</a>
<a class="login-close-text" data-i18n="app.close">Close</a>
{{#if loggingIn}}
{{> _loginButtonsLoggingIn}}
{{/if}}
Expand Down Expand Up @@ -109,15 +109,15 @@

<div class="login-button login-button-form-submit" id="login-buttons-password">
{{#if inSignupFlow}}
<span data-i18n="accountsUI.createAccount">{{i18n "accountsUI.createAccount"}}</span>
<span data-i18n="accountsUI.createAccount">Create an Account</span>
{{/if}}
{{#if inLoginFlow}}
<span data-i18n="accountsUI.signIn">{{i18n "accountsUI.signIn"}}</span>
<span data-i18n="accountsUI.signIn">Sign In</span>
{{/if}}
{{#if inline }}
{{#if canCheckoutAsGuest}}
{{#if inLoginAsGuestFlow}}
<span data-i18n="accountsUI.checkoutAsGuest">{{i18n "accountsUI.checkoutAsGuest"}}</span>
<span data-i18n="accountsUI.checkoutAsGuest">Checkout without user account</span>
{{/if}}
{{/if}}
{{/if}}
Expand All @@ -131,7 +131,7 @@
{{#if showForgotPasswordLink}}
<div class="additional-link-container">
<a id="forgot-password-link" class="additional-link">
<span data-i18n="accountsUI.forgotPassword">{{i18n "accountsUI.forgotPassword"}}</span>
<span data-i18n="accountsUI.forgotPassword">Reset password</span>
</a>
</div>
{{/if}}
Expand Down Expand Up @@ -162,7 +162,7 @@
<template name="core_forgotPasswordForm">
<div class="login-form">
<div id="forgot-password-email-label-and-input"> {{! XXX we should probably use loginButtonsFormField }}
<label id="forgot-password-email-label" for="forgot-password-email" data-i18n="accountsUI.email">{{i18n "accountsUI.email"}}</label>
<label id="forgot-password-email-label" for="forgot-password-email" data-i18n="accountsUI.email">Email</label>
<input id="forgot-password-email" type="email"/>
</div>

Expand All @@ -179,20 +179,20 @@
<template name="_loginButtonsBackToSignUpLink">
<div class="additional-link-container">
<a id="signup-link" class="additional-link">
<span data-i18n="accountsUI.createAccount">{{i18n "accountsUI.createAccount"}}</span>
<span data-i18n="accountsUI.createAccount">Create an Account</span>
</a>
</div>
</template>

<template name="core_loginButtonsBackToLoginLink">
<div class="additional-link-container">
<a id="back-to-login-link" class="additional-link" data-i18n="accountsUI.signIn">{{i18n "accountsUI.signIn"}}</a>
<a id="back-to-login-link" class="additional-link" data-i18n="accountsUI.signIn">Sign In</a>
</div>
</template>

<template name="core_loginButtonsBackToGuestLoginLink">
<div class="additional-link-container">
<a id="back-to-guest-login-link" class="additional-link" data-i18n="accountsUI.checkoutAsGuest">{{i18n "accountsUI.checkoutAsGuest"}}</a>
<a id="back-to-guest-login-link" class="additional-link" data-i18n="accountsUI.checkoutAsGuest">Checkout without user account</a>
</div>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
id="login-buttons-{{name}}">
<div class="login-image" id="login-buttons-image-{{name}}"></div>
{{#if configured}}
<span class="text-besides-image sign-in-text-{{name}}">Sign in with {{capitalizedName}}</span>
<span class="text-besides-image sign-in-text-{{name}}">
<span data-i18n="accountsUI.signInWith">Sign in with</span>
<span data-i18n="social.{{name}}"> {{capitalizedName}}</span>
</span>
{{else}}
<span class="text-besides-image configure-text-{{name}}">Configure {{capitalizedName}} Login</span>
<span class="text-besides-image configure-text-{{name}}">
<span data-i18n="accountsUI.configure">Configure</span>
<span data-i18n="social.{{name}}"> {{capitalizedName}}</span>
</span>
{{/if}}
</div>
</div>
Expand All @@ -23,7 +29,7 @@
<div class="login-display-name">
{{displayName}}
</div>
<div class="login-button single-login-button" id="login-buttons-logout">Sign Out</div>
<div class="login-button single-login-button" id="login-buttons-logout" data-i18n="accountsUI.signOut">Sign Out</div>
</div>
</template>

Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
loginButtonsSession = Accounts._loginButtonsSession


Template.accounts.helpers
chooseTemplate: (name) ->
name = this.valueOf()
return Template[name]

Template.accounts.events
"click #login-buttons-password": ->
loginOrSignup()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<template name="accounts">
{{>chooseTemplate tpl}}
{{> Template.dynamic template=tpl}}
</template>

0 comments on commit 6241d69

Please sign in to comment.