solidus_auth_devise_devise_token_auth 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +173 -0
- data/Gemfile +36 -0
- data/LICENSE.md +26 -0
- data/README.md +98 -0
- data/Rakefile +21 -0
- data/app/mailers/spree/user_mailer.rb +15 -0
- data/app/models/spree/auth_configuration.rb +9 -0
- data/app/models/spree/user.rb +47 -0
- data/app/overrides/auth_admin_login_navigation_bar.rb +10 -0
- data/app/overrides/auth_shared_login_bar.rb +10 -0
- data/bin/rails +7 -0
- data/circle.yml +6 -0
- data/config/initializers/devise.rb +141 -0
- data/config/initializers/warden.rb +14 -0
- data/config/locales/de.yml +53 -0
- data/config/locales/en.yml +54 -0
- data/config/locales/es.yml +50 -0
- data/config/locales/fr.yml +50 -0
- data/config/locales/it.yml +76 -0
- data/config/locales/nl.yml +50 -0
- data/config/locales/pt-BR.yml +52 -0
- data/config/locales/tr.yml +50 -0
- data/config/locales/zh-CN.yml +54 -0
- data/config/routes.rb +71 -0
- data/db/default/users.rb +75 -0
- data/db/migrate/20101026184949_create_users.rb +29 -0
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +41 -0
- data/db/migrate/20101214150824_convert_user_remember_field.rb +11 -0
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +8 -0
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +9 -0
- data/db/migrate/20140904000425_add_deleted_at_to_users.rb +6 -0
- data/db/migrate/20141002154641_add_confirmable_to_users.rb +7 -0
- data/db/seeds.rb +1 -0
- data/lib/assets/javascripts/spree/backend/solidus_auth.js +1 -0
- data/lib/assets/javascripts/spree/frontend/solidus_auth.js +1 -0
- data/lib/assets/stylesheets/spree/backend/solidus_auth.css +3 -0
- data/lib/assets/stylesheets/spree/frontend/solidus_auth.css +3 -0
- data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +11 -0
- data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +15 -0
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +41 -0
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +43 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +66 -0
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +14 -0
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +50 -0
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +40 -0
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +64 -0
- data/lib/controllers/frontend/spree/users_controller.rb +57 -0
- data/lib/generators/solidus/auth/install/install_generator.rb +25 -0
- data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +1 -0
- data/lib/solidus/auth.rb +2 -0
- data/lib/solidus_auth_devise.rb +13 -0
- data/lib/spree/auth/devise.rb +14 -0
- data/lib/spree/auth/engine.rb +80 -0
- data/lib/spree/authentication_helpers.rb +33 -0
- data/lib/tasks/auth.rake +9 -0
- data/lib/views/backend/spree/admin/shared/_navigation_footer.html.erb +25 -0
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +15 -0
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +17 -0
- data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +4 -0
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +31 -0
- data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +13 -0
- data/lib/views/frontend/spree/checkout/registration.html.erb +22 -0
- data/lib/views/frontend/spree/shared/_flashes.html.erb +9 -0
- data/lib/views/frontend/spree/shared/_login.html.erb +18 -0
- data/lib/views/frontend/spree/shared/_login_bar.html.erb +2 -0
- data/lib/views/frontend/spree/shared/_login_bar_items.html.erb +6 -0
- data/lib/views/frontend/spree/shared/_user_form.html.erb +17 -0
- data/lib/views/frontend/spree/user_mailer/confirmation_instructions.text.erb +5 -0
- data/lib/views/frontend/spree/user_mailer/reset_password_instructions.text.erb +10 -0
- data/lib/views/frontend/spree/user_passwords/edit.html.erb +17 -0
- data/lib/views/frontend/spree/user_passwords/new.html.erb +17 -0
- data/lib/views/frontend/spree/user_registrations/new.html.erb +21 -0
- data/lib/views/frontend/spree/user_sessions/authorization_failure.html.erb +4 -0
- data/lib/views/frontend/spree/user_sessions/new.html.erb +13 -0
- data/lib/views/frontend/spree/users/edit.html.erb +14 -0
- data/lib/views/frontend/spree/users/show.html.erb +43 -0
- data/solidus_auth_devise.gemspec +41 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +196 -0
- data/spec/controllers/spree/products_controller_spec.rb +27 -0
- data/spec/controllers/spree/user_passwords_controller_spec.rb +44 -0
- data/spec/controllers/spree/user_registrations_controller_spec.rb +96 -0
- data/spec/controllers/spree/user_sessions_controller_spec.rb +113 -0
- data/spec/controllers/spree/users_controller_spec.rb +38 -0
- data/spec/factories/confirmed_user.rb +7 -0
- data/spec/features/account_spec.rb +58 -0
- data/spec/features/admin/orders_spec.rb +30 -0
- data/spec/features/admin/password_reset_spec.rb +24 -0
- data/spec/features/admin/products_spec.rb +9 -0
- data/spec/features/admin/sign_in_spec.rb +44 -0
- data/spec/features/admin/sign_out_spec.rb +22 -0
- data/spec/features/admin_permissions_spec.rb +46 -0
- data/spec/features/change_email_spec.rb +26 -0
- data/spec/features/checkout_spec.rb +181 -0
- data/spec/features/confirmation_spec.rb +32 -0
- data/spec/features/order_spec.rb +62 -0
- data/spec/features/password_reset_spec.rb +24 -0
- data/spec/features/sign_in_spec.rb +52 -0
- data/spec/features/sign_out_spec.rb +25 -0
- data/spec/features/sign_up_spec.rb +30 -0
- data/spec/mailers/user_mailer_spec.rb +46 -0
- data/spec/models/order_spec.rb +26 -0
- data/spec/models/user_spec.rb +63 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/ability.rb +15 -0
- data/spec/support/authentication_helpers.rb +14 -0
- data/spec/support/confirm_helpers.rb +13 -0
- data/spec/support/email.rb +5 -0
- data/spec/support/preferences.rb +5 -0
- data/spec/support/spree.rb +10 -0
- metadata +446 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
nl:
|
3
|
+
devise:
|
4
|
+
confirmations:
|
5
|
+
confirmed: Je account is succesvol bevestigd. Je bent nu ingelogd.
|
6
|
+
send_instructions: Binnen enkele minuten ontvang je een e-mail om je account te bevestigen.
|
7
|
+
failure:
|
8
|
+
already_authenticated: Je bent reeds aangemeld.
|
9
|
+
inactive: Je account is nog niet geactiveerd.
|
10
|
+
invalid: E-mailadres of wachtwoord is onjuist.
|
11
|
+
invalid_token: Verkeerde authenticatie token.
|
12
|
+
locked: Je account is vergrendeld.
|
13
|
+
timeout: 'Je sessie is verlopen, log opnieuw in om verder te gaan.'
|
14
|
+
unauthenticated: Je moet een account aanmaken voordat je kan verder gaan.
|
15
|
+
unconfirmed: Je moet je account bevestigen voordat je kan verder gaan.
|
16
|
+
mailer:
|
17
|
+
confirmation_instructions:
|
18
|
+
subject: Bevestig je account
|
19
|
+
reset_password_instructions:
|
20
|
+
subject: Wijzig je wachtwoord
|
21
|
+
unlock_instructions:
|
22
|
+
subject: Ontgrendel je account
|
23
|
+
oauth_callbacks:
|
24
|
+
failure: 'We konden je niet autoriseren van %{kind} omdat %{reason}.'
|
25
|
+
success: 'Succesvol geautoriseerd van %{kind} account.'
|
26
|
+
unlocks:
|
27
|
+
send_instructions: Binnen enkele minuten ontvang je een e-mail om je account te ontgrendelen.
|
28
|
+
unlocked: Je account is succesvol ontgrendeld. Je bent nu ingelogd.
|
29
|
+
user_passwords:
|
30
|
+
spree_user:
|
31
|
+
cannot_be_blank: Je wachtwoord kan niet leeg zijn.
|
32
|
+
send_instructions: Binnen enkele minuten ontvang je een e-mail met instructies om je wachtwoord te resetten.
|
33
|
+
updated: Je wachtwoord is succesvol gewijzigd. Je bent nu ingelogd.
|
34
|
+
user_registrations:
|
35
|
+
destroyed: Tot ziens! Je account is succesvol opgezegd. We hopen je snel terug te zien.
|
36
|
+
inactive_signed_up: 'Je bent succesvol aangemeld. Maar we kunnen je niet inloggen omdat je account is %{reason}.'
|
37
|
+
signed_up: Welkom! Je bent succesvol aangemeld.
|
38
|
+
updated: Je account is succesvol aangepast.
|
39
|
+
user_sessions:
|
40
|
+
signed_in: Succesvol ingelogd.
|
41
|
+
signed_out: Succesvol uitgelogd.
|
42
|
+
errors:
|
43
|
+
messages:
|
44
|
+
already_confirmed: is al bevestigd
|
45
|
+
email_is_invalid: e-mail adres mag niet leeg zijn
|
46
|
+
not_found: niet gevonden
|
47
|
+
not_locked: is niet vergrendeld
|
48
|
+
not_saved:
|
49
|
+
one: '1 fout tijdens het opslaan van %{resource}'
|
50
|
+
other: '%{count} fouten tijdens het opslaan van %{resource}'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
pt-BR:
|
3
|
+
spree:
|
4
|
+
admin_login: "Entrada do Administrador"
|
5
|
+
devise:
|
6
|
+
confirmations:
|
7
|
+
confirmed: Sua conta foi confirmada com sucesso. Agora você está conectado.
|
8
|
+
send_instructions: Você receberá um e-mail com instruções sobre como confirmar sua conta em poucos minutos.
|
9
|
+
failure:
|
10
|
+
already_authenticated: Você já está autenticado.
|
11
|
+
inactive: Sua conta não foi ativada ainda.
|
12
|
+
invalid: Email ou senha inválida.
|
13
|
+
invalid_token: Token de autenticação inválido.
|
14
|
+
locked: Sua conta está bloqueada.
|
15
|
+
timeout: 'Sua sessão expirou, por favor entre novamente para continuar.'
|
16
|
+
unauthenticated: Você precisa conectar ou cadastrar-se antes de continuar.
|
17
|
+
unconfirmed: Voce tem que confirmar sua conta antes de continuar.
|
18
|
+
mailer:
|
19
|
+
confirmation_instructions:
|
20
|
+
subject: Instruções de confirmação
|
21
|
+
reset_password_instructions:
|
22
|
+
subject: Instruções de redefinição de senha
|
23
|
+
unlock_instructions:
|
24
|
+
subject: Instruções de desbloqueio
|
25
|
+
oauth_callbacks:
|
26
|
+
failure: '%{kind} não foi autorizada porque %{reason}.'
|
27
|
+
success: 'Conta %{kind} foi autorizada com sucesso.'
|
28
|
+
unlocks:
|
29
|
+
send_instructions: Você receberá um e-mail com instruções sobre como desbloquear sua conta em poucos minutos.
|
30
|
+
unlocked: Sua conta foi desbloqueada com sucesso. Agora você está conectado.
|
31
|
+
user_passwords:
|
32
|
+
spree_user:
|
33
|
+
cannot_be_blank: Sua senha não pode estar em branco.
|
34
|
+
send_instructions: Você receberá um e-mail com instruções sobre como redefinir sua senha em poucos minutos.
|
35
|
+
updated: Sua senha foi alterada com sucesso. Agora você está conectado.
|
36
|
+
user_registrations:
|
37
|
+
destroyed: Até logo! Sua conta foi cancelada com sucesso. Esperamos ver você em breve.
|
38
|
+
inactive_signed_up: 'Seu cadastro foi feito com sucesso. No entanto, não o conectamos porque sua conta está %{reason}.'
|
39
|
+
signed_up: Bem vindo! Seu cadastro foi feito com sucesso.
|
40
|
+
updated: Sua conta foi atualizada com sucesso.
|
41
|
+
user_sessions:
|
42
|
+
signed_in: Entrou com sucesso.
|
43
|
+
signed_out: Saiu com sucesso.
|
44
|
+
errors:
|
45
|
+
messages:
|
46
|
+
already_confirmed: já foi confirmado
|
47
|
+
email_is_invalid: E-mail não pode estar em branco
|
48
|
+
not_found: não encontrado
|
49
|
+
not_locked: não bloqueado
|
50
|
+
not_saved:
|
51
|
+
one: '1 erro não permitiu este %{resource} ser salvo:'
|
52
|
+
other: '%{count} erros não permitiram %{resource} ser salvo:'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
tr:
|
3
|
+
devise:
|
4
|
+
confirmations:
|
5
|
+
confirmed: Hesabınız başarıyla doğrulandı. Oturumunuz açıldı.
|
6
|
+
send_instructions: Birkaç dakika içinde hesabınızı nasıl doğrulayacağınızı anlatan bir e-posta alacaksınız.
|
7
|
+
failure:
|
8
|
+
already_authenticated: Zaten giriş yaptınız.
|
9
|
+
inactive: Hesabınız henüz faal değil.
|
10
|
+
invalid: Geçersiz e-posta ya da şifre.
|
11
|
+
invalid_token: Geçersiz anahtar.
|
12
|
+
locked: Hesabınız kilitlendi.
|
13
|
+
timeout: 'Oturumunuzun süresi doldu, devam etmek için lütfen giriş yapın.'
|
14
|
+
unauthenticated: Devam etmek için üye olmalı ya da giriş yapmalısınız.
|
15
|
+
unconfirmed: Devam etmek için hesabınızı doğrulamalısınız.
|
16
|
+
mailer:
|
17
|
+
confirmation_instructions:
|
18
|
+
subject: Doğrulama Talimatları
|
19
|
+
reset_password_instructions:
|
20
|
+
subject: Şifre Sıfırlama Talimatları
|
21
|
+
unlock_instructions:
|
22
|
+
subject: Kilit Açma Talimatları
|
23
|
+
oauth_callbacks:
|
24
|
+
failure: 'Sizi %{kind} üzerinden %{reason} sebebiyle yetkilendiremedik.'
|
25
|
+
success: '%{kind} hesabından başarıyla yetkilendirildiniz.'
|
26
|
+
unlocks:
|
27
|
+
send_instructions: Birkaç dakika içinde hesabınızın kilidini nasıl açacağınızı anlatan bir e-posta alacaksınız.
|
28
|
+
unlocked: Hesabınızın kilidi başarıyla açıldı. Oturumunuz açıldı.
|
29
|
+
user_passwords:
|
30
|
+
spree_user:
|
31
|
+
cannot_be_blank: Boş parola giremezsiniz.
|
32
|
+
send_instructions: Birkaç dakika içinde şifrenizi nasıl yeniden ayarlayacağınızı anlatan bir e-posta alacaksınız.
|
33
|
+
updated: Şifreniz başarıyla değiştirildi. Oturumunuz açıldı.
|
34
|
+
user_registrations:
|
35
|
+
destroyed: Güle Güle! Hesabınız başarıyla iptal edildi. Sizi tekrar aramızda görmeyi umuyoruz.
|
36
|
+
inactive_signed_up: 'Başarıyla kayıt oldunuz. Ancak oturumunuzu %{reason} sebebiyle açamadık.'
|
37
|
+
signed_up: 'Hoşgeldiniz! Başarıyla kayıt oldunuz.'
|
38
|
+
updated: Hesabınız başarıyla güncellendi.
|
39
|
+
user_sessions:
|
40
|
+
signed_in: Giriş başarılı oldu.
|
41
|
+
signed_out: Çıkış başarılı oldu.
|
42
|
+
errors:
|
43
|
+
messages:
|
44
|
+
already_confirmed: zaten doğrulanmış
|
45
|
+
email_is_invalid: e-posta adresi boş olamaz
|
46
|
+
not_found: kayıt yok
|
47
|
+
not_locked: kilitli değil
|
48
|
+
not_saved:
|
49
|
+
one: '1 hata yüzünden %{resource} kaynağı kaydedilemedi:'
|
50
|
+
other: '%{count} sayıda hata yüzünden %{resource} kaynağı kaydedilemedi:'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
zh-CN:
|
3
|
+
spree:
|
4
|
+
admin_login:
|
5
|
+
devise:
|
6
|
+
confirmations:
|
7
|
+
confirmed: 账户确认成功,现已登录。
|
8
|
+
send_instructions: 稍后您将收到邮件,了解如何确认账户。
|
9
|
+
failure:
|
10
|
+
already_authenticated: 登录成功
|
11
|
+
inactive: 您的账户尚未激活。
|
12
|
+
invalid: 邮箱或密码错误。
|
13
|
+
invalid_token: 验证凭证错误。
|
14
|
+
locked: 账户已锁定。
|
15
|
+
timeout: 账户闲置时间过长,请重新登录。
|
16
|
+
unauthenticated: 请注册或登录,然后继续。
|
17
|
+
unconfirmed: 请确认账户,然后继续。
|
18
|
+
mailer:
|
19
|
+
confirmation_instructions:
|
20
|
+
subject: 确认说明
|
21
|
+
reset_password_instructions:
|
22
|
+
subject: 密码重置说明
|
23
|
+
unlock_instructions:
|
24
|
+
subject: 解锁说明
|
25
|
+
oauth_callbacks:
|
26
|
+
failure: 无法从%{kind}授权,原因为 %{reason}。
|
27
|
+
success: 从%{kind}账户授权成功。
|
28
|
+
unlocks:
|
29
|
+
send_instructions: 稍后您将收到邮件,了解如何解锁账户。
|
30
|
+
unlocked: 账户解锁成功,现已登录。
|
31
|
+
user_passwords:
|
32
|
+
spree_user:
|
33
|
+
cannot_be_blank: 密码不能为空。
|
34
|
+
no_token: 若需访问本页面,请使用重置密码邮件中网址链接,并确保该网址完整。
|
35
|
+
send_instructions: 稍后您将收到邮件,了解如何重置密码。
|
36
|
+
updated: 密码修改成功,现已登录。
|
37
|
+
user_registrations:
|
38
|
+
destroyed: 账户已成功取消,再会啦,期待着您的早日回归!
|
39
|
+
inactive_signed_up: 注册成功!但暂时无法登录账户,原因为%{reason}。
|
40
|
+
signed_up: 祝贺您!注册成功。
|
41
|
+
updated: 账户更新成功。
|
42
|
+
user_sessions:
|
43
|
+
signed_in: 登录成功。
|
44
|
+
signed_out: 登出成功。
|
45
|
+
already_signed_in: 已登录。
|
46
|
+
errors:
|
47
|
+
messages:
|
48
|
+
already_confirmed: 已确认
|
49
|
+
email_is_invalid: 邮箱地址不能为空
|
50
|
+
not_found: 未找到
|
51
|
+
not_locked: 未锁定
|
52
|
+
not_saved:
|
53
|
+
one: '出现1处错误,%{resource}无法保存'
|
54
|
+
other: '出现%{count}处错误,%{resource}无法保存'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
Spree::Core::Engine.routes.draw do
|
2
|
+
if (
|
3
|
+
SolidusSupport.frontend_available? &&
|
4
|
+
Spree::Auth::Config.draw_frontend_routes
|
5
|
+
)
|
6
|
+
|
7
|
+
devise_for(:spree_user, {
|
8
|
+
class_name: 'Spree::User',
|
9
|
+
controllers: {
|
10
|
+
sessions: 'spree/user_sessions',
|
11
|
+
registrations: 'spree/user_registrations',
|
12
|
+
passwords: 'spree/user_passwords',
|
13
|
+
confirmations: 'spree/user_confirmations'
|
14
|
+
},
|
15
|
+
skip: [:unlocks, :omniauth_callbacks],
|
16
|
+
path_names: { sign_out: 'logout' },
|
17
|
+
path_prefix: :user
|
18
|
+
})
|
19
|
+
|
20
|
+
resources :users, only: [:edit, :update]
|
21
|
+
|
22
|
+
devise_scope :spree_user do
|
23
|
+
get '/login', to: 'user_sessions#new', as: :login
|
24
|
+
post '/login', to: 'user_sessions#create', as: :create_new_session
|
25
|
+
match '/logout', to: 'user_sessions#destroy', as: :logout, via: Devise.sign_out_via
|
26
|
+
get '/signup', to: 'user_registrations#new', as: :signup
|
27
|
+
post '/signup', to: 'user_registrations#create', as: :registration
|
28
|
+
get '/password/recover', to: 'user_passwords#new', as: :recover_password
|
29
|
+
post '/password/recover', to: 'user_passwords#create', as: :reset_password
|
30
|
+
get '/password/change', to: 'user_passwords#edit', as: :edit_password
|
31
|
+
put '/password/change', to: 'user_passwords#update', as: :update_password
|
32
|
+
get '/confirm', to: 'user_confirmations#show', as: :confirmation if Spree::Auth::Config[:confirmable]
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/checkout/registration', to: 'checkout#registration', as: :checkout_registration
|
36
|
+
put '/checkout/registration', to: 'checkout#update_registration', as: :update_checkout_registration
|
37
|
+
|
38
|
+
resource :account, controller: 'users'
|
39
|
+
end
|
40
|
+
|
41
|
+
if (
|
42
|
+
SolidusSupport.backend_available? &&
|
43
|
+
Spree::Auth::Config.draw_backend_routes
|
44
|
+
)
|
45
|
+
|
46
|
+
namespace :admin do
|
47
|
+
devise_for(:spree_user, {
|
48
|
+
class_name: 'Spree::User',
|
49
|
+
singular: :spree_user,
|
50
|
+
skip: :all,
|
51
|
+
path_names: { sign_out: 'logout' },
|
52
|
+
controllers: {
|
53
|
+
sessions: 'spree/admin/user_sessions',
|
54
|
+
passwords: 'spree/admin/user_passwords'
|
55
|
+
},
|
56
|
+
})
|
57
|
+
|
58
|
+
devise_scope :spree_user do
|
59
|
+
get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized
|
60
|
+
get '/login', to: 'user_sessions#new', as: :login
|
61
|
+
post '/login', to: 'user_sessions#create', as: :create_new_session
|
62
|
+
get '/logout', to: 'user_sessions#destroy', as: :logout
|
63
|
+
|
64
|
+
get '/password/recover', to: 'user_passwords#new', as: :recover_password
|
65
|
+
post '/password/recover', to: 'user_passwords#create', as: :reset_password
|
66
|
+
get '/password/change', to: 'user_passwords#edit', as: :edit_password
|
67
|
+
put '/password/change', to: 'user_passwords#update', as: :update_password
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/db/default/users.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# see last line where we create an admin if there is none, asking for email and password
|
2
|
+
def prompt_for_admin_password
|
3
|
+
if ENV['ADMIN_PASSWORD']
|
4
|
+
password = ENV['ADMIN_PASSWORD'].dup
|
5
|
+
puts "Admin Password #{password}"
|
6
|
+
else
|
7
|
+
print "Password [test123]: "
|
8
|
+
password = STDIN.gets.strip
|
9
|
+
password = 'test123' if password.blank?
|
10
|
+
end
|
11
|
+
|
12
|
+
password
|
13
|
+
end
|
14
|
+
|
15
|
+
def prompt_for_admin_email
|
16
|
+
if ENV['ADMIN_EMAIL']
|
17
|
+
email = ENV['ADMIN_EMAIL'].dup
|
18
|
+
puts "Admin User #{email}"
|
19
|
+
else
|
20
|
+
print "Email [admin@example.com]: "
|
21
|
+
email = STDIN.gets.strip
|
22
|
+
email = 'admin@example.com' if email.blank?
|
23
|
+
end
|
24
|
+
|
25
|
+
email
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_admin_user
|
29
|
+
if ENV['AUTO_ACCEPT']
|
30
|
+
password = 'test123'
|
31
|
+
email = 'admin@example.com'
|
32
|
+
else
|
33
|
+
puts 'Create the admin user (press enter for defaults).'
|
34
|
+
#name = prompt_for_admin_name unless name
|
35
|
+
email = prompt_for_admin_email
|
36
|
+
password = prompt_for_admin_password
|
37
|
+
end
|
38
|
+
attributes = {
|
39
|
+
:password => password,
|
40
|
+
:password_confirmation => password,
|
41
|
+
:email => email,
|
42
|
+
:login => email
|
43
|
+
}
|
44
|
+
|
45
|
+
load 'spree/user.rb'
|
46
|
+
|
47
|
+
if Spree::User.find_by_email(email)
|
48
|
+
puts "\nWARNING: There is already a user with the email: #{email}, so no account changes were made. If you wish to create an additional admin user, please run rake spree_auth:admin:create again with a different email.\n\n"
|
49
|
+
else
|
50
|
+
admin = Spree::User.new(attributes)
|
51
|
+
if admin.save
|
52
|
+
role = Spree::Role.find_or_create_by(name: 'admin')
|
53
|
+
admin.spree_roles << role
|
54
|
+
admin.save
|
55
|
+
puts "Done!"
|
56
|
+
else
|
57
|
+
puts "There was some problems with persisting new admin user:"
|
58
|
+
admin.errors.full_messages.each do |error|
|
59
|
+
puts error
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
if Spree::User.admin.empty?
|
66
|
+
create_admin_user
|
67
|
+
else
|
68
|
+
puts 'Admin user has already been previously created.'
|
69
|
+
puts 'Would you like to create a new admin user? (yes/no)'
|
70
|
+
if ["yes", "y"].include? STDIN.gets.strip.downcase
|
71
|
+
create_admin_user
|
72
|
+
else
|
73
|
+
puts 'No admin user created.'
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateUsers < SolidusSupport::Migration[4.2]
|
2
|
+
def up
|
3
|
+
unless table_exists?("spree_users")
|
4
|
+
create_table "spree_users", :force => true do |t|
|
5
|
+
t.string "crypted_password", :limit => 128
|
6
|
+
t.string "salt", :limit => 128
|
7
|
+
t.string "email"
|
8
|
+
t.string "remember_token"
|
9
|
+
t.string "remember_token_expires_at"
|
10
|
+
t.string "persistence_token"
|
11
|
+
t.string "single_access_token"
|
12
|
+
t.string "perishable_token"
|
13
|
+
t.integer "login_count", :default => 0, :null => false
|
14
|
+
t.integer "failed_login_count", :default => 0, :null => false
|
15
|
+
t.datetime "last_request_at"
|
16
|
+
t.datetime "current_login_at"
|
17
|
+
t.datetime "last_login_at"
|
18
|
+
t.string "current_login_ip"
|
19
|
+
t.string "last_login_ip"
|
20
|
+
t.string "login"
|
21
|
+
t.integer "ship_address_id"
|
22
|
+
t.integer "bill_address_id"
|
23
|
+
t.datetime "created_at", :null => false
|
24
|
+
t.datetime "updated_at", :null => false
|
25
|
+
t.string "openid_identifier"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class RenameColumnsForDevise < SolidusSupport::Migration[4.2]
|
2
|
+
def up
|
3
|
+
return if column_exists?(:spree_users, :password_salt)
|
4
|
+
if column_exists?(:spree_users, :crypted_password)
|
5
|
+
rename_column :spree_users, :crypted_password, :encrypted_password
|
6
|
+
end
|
7
|
+
if column_exists?(:spree_users, :salt)
|
8
|
+
rename_column :spree_users, :salt, :password_salt
|
9
|
+
end
|
10
|
+
rename_column :spree_users, :remember_token_expires_at, :remember_created_at
|
11
|
+
rename_column :spree_users, :login_count, :sign_in_count
|
12
|
+
rename_column :spree_users, :failed_login_count, :failed_attempts
|
13
|
+
rename_column :spree_users, :single_access_token, :reset_password_token
|
14
|
+
rename_column :spree_users, :current_login_at, :current_sign_in_at
|
15
|
+
rename_column :spree_users, :last_login_at, :last_sign_in_at
|
16
|
+
rename_column :spree_users, :current_login_ip, :current_sign_in_ip
|
17
|
+
rename_column :spree_users, :last_login_ip, :last_sign_in_ip
|
18
|
+
add_column :spree_users, :authentication_token, :string
|
19
|
+
add_column :spree_users, :unlock_token, :string
|
20
|
+
add_column :spree_users, :locked_at, :datetime
|
21
|
+
remove_column :spree_users, :openid_identifier
|
22
|
+
end
|
23
|
+
|
24
|
+
def down
|
25
|
+
remove_column :spree_users, :authentication_token
|
26
|
+
remove_column :spree_users, :locked_at
|
27
|
+
remove_column :spree_users, :unlock_token
|
28
|
+
rename_column :spree_users, :last_sign_in_ip, :last_login_ip
|
29
|
+
rename_column :spree_users, :current_sign_in_ip, :current_login_ip
|
30
|
+
rename_column :spree_users, :last_sign_in_at, :last_login_at
|
31
|
+
rename_column :spree_users, :current_sign_in_at, :current_login_at
|
32
|
+
rename_column :spree_users, :reset_password_token, :single_access_token
|
33
|
+
rename_column :spree_users, :failed_attempts, :failed_login_count
|
34
|
+
rename_column :spree_users, :sign_in_count, :login_count
|
35
|
+
rename_column :spree_users, :remember_created_at, :remember_token_expires_at
|
36
|
+
rename_column :spree_users, :password_salt, :salt
|
37
|
+
rename_column :spree_users, :encrypted_password, :crypted_password
|
38
|
+
add_column :spree_users, :unlock_token, :string
|
39
|
+
add_column :spree_users, :openid_identifier, :string
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ConvertUserRememberField < SolidusSupport::Migration[4.2]
|
2
|
+
def up
|
3
|
+
remove_column :spree_users, :remember_created_at
|
4
|
+
add_column :spree_users, :remember_created_at, :datetime
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
remove_column :spree_users, :remember_created_at
|
9
|
+
add_column :spree_users, :remember_created_at, :string
|
10
|
+
end
|
11
|
+
end
|