def change_password
    unless current_user
      bounce_user
      return
    end

    @credential = current_user.credentials.
                               where(type:  'Credentials::Password').first
    if @credential
      # An old password is set, must verify it.
      if @credential.check_password params[:credential][:old_password]
        success = @credential.update_attributes change_password_params
      else
        success = false
        flash[:alert] = 'Incorrect old password. Please try again.'
      end
    else
      @credential = Credentials::Password.new change_password_params
      @credential.user = current_user
      success = @credential.save
    end
    respond_to do |format|
      if success
        format.html do
          redirect_to session_url, notice: 'Password updated'
        end
        format.json { head :no_content }
      else
        format.html { render action: :password_change }
        format.json { render json: { error: :invalid } }
      end
    end
  end
def change_password
    unless current_user
      bounce_user
      return
    end

    @credential = current_user.credentials.
                               where(type:  'Credentials::Password').first
    if @credential
      # An old password is set, must verify it.
      if @credential.check_password params[:credential][:old_password]
        success = @credential.update_attributes change_password_params
      else
        success = false
        flash[:alert] = 'Incorrect old password. Please try again.'
      end
    else
      @credential = Credentials::Password.new change_password_params
      @credential.user = current_user
      success = @credential.save
    end
    respond_to do |format|
      if success
        format.html do
          redirect_to session_url, notice: 'Password updated'
        end
        format.json { head :no_content }
      else
        format.html { render action: :password_change }
        format.json { render json: { error: :invalid } }
      end
    end
  end
POST /session/change_password