def auth_token
end
- def approbe
+ def create_token
+ @admin = current_admin
+ respond_to do |format|
+ if @admin.create_token
+ format.html { redirect_to({:action => :auth_token}, {:notice => 'admin token was successfully created.'}) }
+ else
+ format.html { render action: "auth_token" }
+ end
+ end
+ end
+
+ def delete_token
+ current_admin.delete_token
+ respond_to do |format|
+ format.html { redirect_to :action => :auth_token}
+ end
+ end
+
+ def approve
+ @admin = Admin.find params[:id]
+ respond_to do |format|
+ if @admin.apv
+ format.html { redirect_to({:action => :waiting_list}, {:notice => 'admin was successfully approved.'}) }
+ else
+ format.html { render action: "waiting_list" }
+ end
+ end
end
def waiting_list
- @newadmins = Admin.find(:all, :conditions => ['activate = 0'])
+ @waits = Admin.find(:all, :conditions => ['approve = 0'])
end
def accept_admin
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
- before_save :ensure_authentication_token\r
def active_for_authentication?\r
- super && (self.approve == 1)\r
+ super && (self.approve == 1)
end
+ def create_token
+ self.ensure_authentication_token
+ self.save
+ end
+
+ def delete_token
+ self.authentication_token = nil
+ self.save
+ end
+
+ def apv
+ self.approve = 1
+ self.save
+ end
+
def self.start(email, passwd)
- a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
+ a = Admin.find(:first, :conditions => ['email = ?', email])
+ if a
+ a.password = passwd
+ a.password_confirmation = passwd
+ else
+ a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
+ end
a.approve = 1
a.save!
end
</div>
<div>
<%= link_to "browse", :controller => '/system', :action => :browse%>
- <%= link_to "approbe", :controller => '/system', :action => :approbe%>
+ <%= link_to "approve", :controller => '/system', :action => :waiting_list%>
<%= link_to "token", :controller => '/system', :action => :auth_token%>
</div>
<%= yield %>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
</div>
+<div>
authentication_token:<%= current_admin.authentication_token %>
+</div>
-<%= link_to 'generate token', :action => :create_token %>
-<%= link_to 'delete token', :action => :delete_token %>
+<div>
+ <% if current_admin.authentication_token %>
+ <%= link_to 'delete token', :action => :delete_token %>
+ <% else %>
+ <%= link_to 'generate token', :action => :create_token %>
+ <% end %>
+</div>
<%= link_to 'browse', :action => :browse %>
</div>
<div>
+ <%= link_to 'approve', :action => :waiting_list %>
+</div>
+<div>
<%= link_to 'auth token', :action => :auth_token %>
</div>
<div>
-<h1>Listing artists</h1>
+<div>
+ <p class="notice"><%= notice %></p>
+ <p class="alert"><%= alert %></p>
+</div>
+<h1>Listing waiting admins</h1>
<table>
<tr>
- <th>author</th>
- <th></th>
+ <th>id</th>
+ <th>email</th>
+ <th>sign_in_count</th>
+ <th>current_sign_in_at</th>
+ <th>last_sign_in_at</th>
+ <th>current_sign_in_ip</th>
+ <th>last_sign_in_ip</th>
+ <th>created_at</th>
+ <th>updated_at</th>
</tr>
-<% @artists.each do |artist| %>
+<% @waits.each do |admin| %>
<tr>
- <td><%= artist.author_id %></td>
- <td><%= link_to 'Show', artist %></td>
+ <td><%= admin.id %></td>
+ <td><%= h(admin.email) %></td>
+ <td><%= admin.sign_in_count %></td>
+ <td><%= admin.current_sign_in_at %></td>
+ <td><%= admin.last_sign_in_at %></td>
+ <td><%= admin.current_sign_in_ip %></td>
+ <td><%= admin.last_sign_in_ip %></td>
+ <td><%= admin.created_at %></td>
+ <td><%= admin.updated_at %></td>
+ <td><%= link_to 'approve', :controller => '/system', :action => :approve, :id => admin.id %></td>
</tr>
<% end %>
</table>