authlogic

prepopulating admin user in database with authlogic rails plugin

浪尽此生 提交于 2019-12-07 08:45:33
问题 I've been using the Authlogic rails plugin. Really all I am using it for is to have one admin user who can edit the site. It's not a site where people sign up accounts. I'm going to end up making the create user method restricted by an already logged in user, but of course, when I clear the DB I can't create a user, so I have to prepopulate it somehow. I tried just making a migration to put a dump of a user I created but that doesn't work and seems pretty hacky. What's the best way to handle

Protecting Content with AuthLogic

核能气质少年 提交于 2019-12-07 07:35:34
问题 I know this sounds like a really, really simple use case and I'm hoping that it is, but I swear I've looked all over the place and haven't found any mention of any way - not even the best way - of doing this. I'm brand-spanking new to Ruby, Rails and everything surrounding either (which may explain a lot ). The dummy app that I'm using as my learning tool requires authentication in order to do almost anything meaningful, so I chose to start by solving that problem. I've installed the

validating password format in Authlogic

♀尐吖头ヾ 提交于 2019-12-07 02:02:42
问题 Is there a way to get Authlogic to validate the format of a password, for instance must contain at least one letter and at least one number? The omission of a validates_format_of_password_options method to be used in the acts_as_authentic config block seems to indicate that Authlogic has the opinion that one should not be imposing such a constraint on one's users. I thought I would simply put in a normal ActiveRecord validates_format_of :password , but this means that a current_user object I

Log-in through authlogic without having to fill in form every time

£可爱£侵袭症+ 提交于 2019-12-07 01:15:39
问题 I have a number of Cucumber scenarios which run with capybara on a project I am working on. Most of these scenarios start with a "Given I am logged in" step. Currently my implementation of this is: visit path_to('the login page') fill_in('Username', :with => 'user') fill_in('Password', :with => 'password') click_button('Login') This works fine, however it is becoming a bit time consuming having to load and submit the login form before every single scenario. Is there a way to simply set up the

Problem with Authlogic and Unit/Functional Tests in Rails

半城伤御伤魂 提交于 2019-12-06 16:13:41
问题 I'm learning how unit testing is done in Rails, and I've run into a problem involving Authlogic. According to the Documentation there are a few things required to use Authlogic stuff in your tests: test_helper.rb: require "authlogic/test_case" class ActiveSupport::TestCase setup :activate_authlogic end Then in my functional tests I can login users: UserSession.create(users(:tester)) The problem seems to stem from the setup :activate_authlogic line in test_helper.rb, whenever that is included,

devise routing error

限于喜欢 提交于 2019-12-06 07:23:19
问题 I can't seem to get past this error when setting up devise. Routing Error wrong constant name Devise/registrationsController or Routing Error wrong constant name Devise/sessionsController I'm using Ruby 1.8.7, Rails 3.0 and Devise 1.1.3 Everything else on my app works, I recently upgraded my app from 2.3.8 and was previously using authlogic but didn't have any users other than myself so I just jettisoned my User, Session models and User, UserSession controllers... so I'm figuring that has

what is the omniauth & email-password registration best practice?

萝らか妹 提交于 2019-12-06 05:54:25
问题 What is the best practice for combining Facebook login (let's say I'll use Omniauth gem) and email+password login? I saw a few blogs, saw the Railscasts, I know everyone is using Devise gem with Omniauth. But I'm looking for some different perspective. subquestions: I'm considering creating email+password sign-up from scratch (not using any gem for this, lets keep it fast and light) so do you have any advice for this ? Or if you have particular gem in mind, please let it be fast. And do you

The Authlogic record method. What does this do

坚强是说给别人听的谎言 提交于 2019-12-06 01:51:39
问题 I came across this method called record that Ryan bates uses in his authlogic Railscast and can't seem to understand what it does. I have been through the documentation but I can't seem to follow how that helper is useful. def current_user return @current_user if defined?(@current_user) current_user_session && current_user_session.record end What I want to know is does this simply fetch the record from the database and why is it different from the standard way of fetching data from the

Rails and Authlogic: Allow only one session per user?

耗尽温柔 提交于 2019-12-05 21:30:41
Is there a way to limit the number of sessions in Ruby on Rails application (I'm using Authlogic for authentication)? I would like to allow only 1 session per user account. When the same user is logging on another computer the previous session should be expired/invalidated. I was thinking about storing the session data in database and then deleting it when a new session instance is created but probably there is an easier way? (configuration option) I just ran into a possible solution, if you reset presistence token you can achieve the intended behaviour: class UserSession < Authlogic::Session:

prepopulating admin user in database with authlogic rails plugin

你。 提交于 2019-12-05 18:33:40
I've been using the Authlogic rails plugin. Really all I am using it for is to have one admin user who can edit the site. It's not a site where people sign up accounts. I'm going to end up making the create user method restricted by an already logged in user, but of course, when I clear the DB I can't create a user, so I have to prepopulate it somehow. I tried just making a migration to put a dump of a user I created but that doesn't work and seems pretty hacky. What's the best way to handle this? It's tricky since the passwords get hashed, so I feel like I have to create one and then pull out