Authlogic::Session::MagicStates - Automatically validates based on the
records states: active?, approved?, and confirmed?. If those methods
exist for the record.
just create a active? method in your user model.
one easy way is to create a boolean column in your user table named
something like active and put this in your user model
def active?
self.active
end
if active? returns true, they can login, if it returns false, they
will be blocked from logging in.
On Jun 1, 9:37 pm, Suec <sueche...@gmail.com> wrote:
Yep, scott has it right. Also, I am pretty sure if you create a
boolean column you get the ? method for free.
Lastly, you can stop the login writing your own validation hook, just
like you would for an AR model. So fi you don't want to use active?
you can define your own method and do whatever you want:
> Authlogic::Session::MagicStates - Automatically validates based on the
> records states: active?, approved?, and confirmed?. If those methods
> exist for the record.
> just create a active? method in your user model.
> one easy way is to create a boolean column in your user table named
> something like active and put this in your user model
> def active?
> self.active
> end
> if active? returns true, they can login, if it returns false, they
> will be blocked from logging in.
> On Jun 1, 9:37 pm, Suec <sueche...@gmail.com> wrote:
>> What is the best way to disable an user(or disable his/her login)?
> Yep, scott has it right. Also, I am pretty sure if you create a
> boolean column you get the ? method for free.
> Lastly, you can stop the login writing your own validation hook, just
> like you would for an AR model. So fi you don't want to use active?
> you can define your own method and do whatever you want:
> 1430 Broadway
> 7th Floor - NECO
> New York, NY 10018
> On Jun 1, 2009, at 11:42 PM, scott wrote:
> > Authlogic::Session::MagicStates - Automatically validates based on the
> > records states: active?, approved?, and confirmed?. If those methods
> > exist for the record.
> > just create a active? method in your user model.
> > one easy way is to create a boolean column in your user table named
> > something like active and put this in your user model
> > def active?
> > self.active
> > end
> > if active? returns true, they can login, if it returns false, they
> > will be blocked from logging in.
> > On Jun 1, 9:37 pm, Suec <sueche...@gmail.com> wrote:
> >> What is the best way to disable an user(or disable his/her login)?
# GET /users/ban/1
def ban
@user = User.find(params[:id])
if superuser == true
@user.update_attribute(:confirmed,0)
flash[:notice] = "{...@user.login} was banned"
else
flash[:notice] = "huh?"
end
respond_to do |format|
format.html { redirect_to(users_path) }
format.xml { head :ok }
end
end
You will also need to define the superuser ; I did this as a private
function ...
def superuser
unless @current_user.id == 1
return false
end
return true
end
Note 1 is the first record in the users table
On Jun 1, 6:37 pm, Suec <sueche...@gmail.com> wrote: