allow user accounts to be deleted

This commit is contained in:
Lee Lawlor 2014-03-13 20:04:31 -04:00
parent 847a513a94
commit f21dea069f
4 changed files with 62 additions and 43 deletions

View File

@ -3,6 +3,14 @@ class UsersController < ApplicationController
skip_before_filter :verify_authenticity_token, :only => [:api_login]
before_filter :require_user, :only => [:show, :edit, :update, :edit_profile]
# delete account
def destroy
user = current_user
user.delete
flash[:notice] = t(:account_deleted)
redirect_to root_path
end
# allow login via api
def api_login
# get the user by login or email

View File

@ -32,19 +32,19 @@
class User < ActiveRecord::Base
include KeyUtilities
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
has_many :channels
has_many :channels, :dependent => :destroy
has_many :twitter_accounts, :dependent => :destroy
has_many :thinghttps, :dependent => :destroy
has_many :tweetcontrols, :dependent => :destroy
has_many :reacts, :dependent => :destroy
has_many :scheduled_thinghttps, :dependent => :destroy
has_many :talkbacks, :dependent => :destroy
has_many :plugins
has_many :devices
has_many :api_keys
has_many :plugins, :dependent => :destroy
has_many :devices, :dependent => :destroy
has_many :api_keys, :dependent => :destroy
has_many :watchings, :dependent => :destroy
has_many :watched_channels, :through => :watchings, :source => :channel
has_many :comments
has_many :watched_channels, :through => :watchings, :source => :channel, :dependent => :destroy
has_many :comments, :dependent => :destroy
self.include_root_in_json = false

View File

@ -1,48 +1,55 @@
<div class="col-sm-8 col-xs-7">
<div class="row">
<div class="col-sm-8 col-xs-7">
<ol class="breadcrumb">
<li><%= link_to t(:myaccount), account_path %></li>
<li class="active"><%= t(:account_edit) %></li>
</ol>
<ol class="breadcrumb">
<li><%= link_to t(:myaccount), account_path %></li>
<li class="active"><%= t(:account_edit) %></li>
</ol>
<%= form_for @user, :url => account_path, :html => {:class => 'form-horizontal'} do |f| %>
<%= error_messages_for 'user', :header_message => t(:try_again), :message => t(:account_error_edit) %>
<input name='userlogin' class='userlogin' />
<%= form_for @user, :url => account_path, :html => {:class => 'form-horizontal'} do |f| %>
<%= error_messages_for 'user', :header_message => t(:try_again), :message => t(:account_error_edit) %>
<input name='userlogin' class='userlogin' />
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:userid) %></label>
<div class="col-sm-8 col-xs-8"><%= f.text_field :login, :class => 'form-control' %></div>
</div>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:email) %></label>
<div class="col-sm-8 col-xs-8"><%= f.text_field :email, :class => 'form-control' %></div>
</div>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:time_zone) %></label>
<div class="col-sm-8 col-xs-8">
<p class="form-control-static">
<%= time_zone_select 'user', 'time_zone', nil, {:default => 'Eastern Time (US & Canada)'}, {:class => 'form-control'} %>
</p>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:userid) %></label>
<div class="col-sm-8 col-xs-8"><%= f.text_field :login, :class => 'form-control' %></div>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:password_change) %></label>
<div class="col-sm-8 col-xs-8"><%= f.password_field :password, :class => 'form-control' %></div>
</div>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:email) %></label>
<div class="col-sm-8 col-xs-8"><%= f.text_field :email, :class => 'form-control' %></div>
</div>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:password_current) %></label>
<div class="col-sm-8 col-xs-8"><%= f.password_field :password_current, :class => 'form-control' %></div>
</div>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:time_zone) %></label>
<div class="col-sm-8 col-xs-8">
<p class="form-control-static">
<%= time_zone_select 'user', 'time_zone', nil, {:default => 'Eastern Time (US & Canada)'}, {:class => 'form-control'} %>
</p>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8 col-xs-offset-4 col-xs-8"><p class="form-control-static"><%= f.submit t(:account_update), :class => 'btn btn-primary' %></p></div>
</div>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:password_change) %></label>
<div class="col-sm-8 col-xs-8"><%= f.password_field :password, :class => 'form-control' %></div>
</div>
<% end %>
<div class="form-group">
<label class="col-sm-4 col-xs-4 control-label"><%= t(:password_current) %></label>
<div class="col-sm-8 col-xs-8"><%= f.password_field :password_current, :class => 'form-control' %></div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8 col-xs-offset-4 col-xs-8"><p class="form-control-static"><%= f.submit t(:account_update), :class => 'btn btn-primary' %></p></div>
</div>
<% end %>
</div>
</div>
<br><br>
<h3><%= t(:account_delete_message) %></h3>
<%= button_to t(:account_delete), user_path(@user.id), :method => 'delete', :data => { :confirm => t(:confirm_account_delete) }, :class => 'btn btn-danger' %>

View File

@ -9,6 +9,9 @@ en:
about: "About"
account: "Account"
account_changes: "Confirm account changes"
account_delete: "Delete Account"
account_deleted: "Your account has been deleted."
account_delete_message: "Want to delete your account?"
account_edit: "Edit Account"
account_error: "There were some problems creating your account:"
account_error_edit: "There were some problems editing your account:"
@ -88,6 +91,7 @@ en:
comment_reply: "reply"
comment_reported: "Reported!"
community: "Community"
confirm_account_delete: "Are you sure you want to delete your account? This cannot be undone."
confirm_read_key_delete: "Are you sure you want to delete this Read API Key?"
confirm_channel_clear: "Are you sure you want to clear this channel?"
confirm_channel_delete: "Are you sure you want to delete this channel?"