# Authlogic admin user functionality

**URL:** <https://www.ruby-forum.com/t/authlogic-admin-user-functionality/191623>\
**Category:** Rails\
**Created:** [July 15, 2010, 2:34pm UTC](https://www.ruby-forum.com/t/authlogic-admin-user-functionality/191623 "2010-07-15T14:34:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sachin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@sachin](https://www.ruby-forum.com/u/sachin)\
**Post date:** [July 15, 2010, 2:34pm UTC](https://www.ruby-forum.com/t/authlogic-admin-user-functionality/191623/1 "2010-07-15T14:34:27Z")

</div>

I am using authlogic as a authentication engine in my rails app.  
I have two types of users 1) Users who are registered and has access  
to there own profile.  
2) Admin user who has access to everybody’s profile

In the user table i have a :is\_admin field boolean field which defines  
the admin user.

like the current\_user method, Is there a way authlogic provides which  
can tell me if the current user is admin?

Any help appreciated…

- S

---

<div class="post-metadata">

**Author:** ![sachin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@sachin](https://www.ruby-forum.com/u/sachin)\
**Post date:** [July 15, 2010, 2:46pm UTC](https://www.ruby-forum.com/t/authlogic-admin-user-functionality/191623/2 "2010-07-15T14:46:45Z")

</div>

On 15 July 2010 13:33, Sachin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am using authlogic as a authentication engine in my rails app.  
> I have two types of users 1) Users who are registered and has access  
> to there own profile.  
> 2) Admin user who has access to everybody’s profile
> 
> In the user table i have a :is\_admin field boolean field which defines  
> the admin user.
> 
> like the current\_user method, Is there a way authlogic provides which  
> can tell me if the current user is admin?

Perhaps I am missing something but I would have thought that  
current\_user.is\_admin  
would have done what you want.

Colin

---

<div class="post-metadata">

**Author:** ![sachin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c77e96/32.png) [@sachin](https://www.ruby-forum.com/u/sachin)\
**Post date:** [July 15, 2010, 3:00pm UTC](https://www.ruby-forum.com/t/authlogic-admin-user-functionality/191623/3 "2010-07-15T15:00:48Z")

</div>

Thanks Colin,  
In the mean i tried a bit and wrote a method named “admin\_user”  
referring to the “current\_user” method in application controller.

def current\_user  
return @current\_user\_session if defined?(@current\_user)  
@current\_user = current\_user\_session &&  
current\_user\_session.record  
end

def admin\_user  
return @current\_user.is\_admin?  
end

Now i am checking both the conditions

if current\_user && admin\_user  
do bla bla …  
end

now it started the working the way i want.

Cheers - S
