Update profile
This commit is contained in:
		
							parent
							
								
									b3e6a3d1c7
								
							
						
					
					
						commit
						00918b93af
					
				@ -53,7 +53,12 @@ class UserController < ApplicationController
 | 
			
		||||
  def update
 | 
			
		||||
    @data = User.collection.find({session_key: Digest::SHA256.hexdigest(request.session['session_id'])}).first
 | 
			
		||||
    unless @data.nil?
 | 
			
		||||
      
 | 
			
		||||
      if request.request_method == 'POST'
 | 
			
		||||
        if params[:name]
 | 
			
		||||
          @data.name = params[:name]
 | 
			
		||||
        end
 | 
			
		||||
        User.collection.update({_id: @data._id}, @data.attributes)
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      render :json => 'wtf?'
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
<div id="registration">
 | 
			
		||||
	<h1>Update ur profile!</h1>
 | 
			
		||||
	<%= form_tag('/reg/complete', :method => 'post') do -%>
 | 
			
		||||
	<%= form_tag('/user/profile', :method => 'post') do -%>
 | 
			
		||||
		<%= label_tag 'email', 'E-mail' %><%= email_field_tag 'email', @data.email %>
 | 
			
		||||
		<%= label_tag 'name', 'Name' %><%= text_field_tag 'name', @data.name %>
 | 
			
		||||
		<%= label_tag 'password', 'Password' %><%= password_field_tag 'password', nil %><div id="password_error"></div>
 | 
			
		||||
@ -16,11 +16,11 @@
 | 
			
		||||
		$('#password').focus();
 | 
			
		||||
		$('form').submit(function(){
 | 
			
		||||
			$('#password_error, #password_c_error').html('');
 | 
			
		||||
			if ($('#password').val().length < 6) {
 | 
			
		||||
			if ($('#password').val().length > 0 && $('#password').val().length < 6) {
 | 
			
		||||
				$('#password_error').html('* Password must be 6+ characters length');
 | 
			
		||||
				$('#password').focus();
 | 
			
		||||
				return false;
 | 
			
		||||
			} else if ($('#password').val() != $('#password_c').val()) {
 | 
			
		||||
			} else if ($('#password').val().length > 0 && $('#password').val() != $('#password_c').val()) {
 | 
			
		||||
				$('#password_c_error').html('* Password and confirmation doesn\'t match');
 | 
			
		||||
				$('#password_c').focus();
 | 
			
		||||
				return false;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user