Code Monkey home page Code Monkey logo

Comments (15)

webvimark avatar webvimark commented on July 28, 2024

I've added ajax validation support. You may check it now

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

I also already did it. But thanks anyway!

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

AJAX validation breaks CAPTCHA. It always incorrect. See yiisoft/yii2#6115

from user-management.

webvimark avatar webvimark commented on July 28, 2024

I fixed it, you may check it now.
Thank you for details on this issue

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

hmmm, don't worked. AJAX response always empty JSON []

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

You are submitting a list of attributes is wrong in ActiveForm::validate($model, $validateAttributes);

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

replace

$validateAttributes = $model->attributes;
unset($validateAttributes['captcha']);

with

$validateAttributes = $model->activeAttributes();
$key = array_search('captcha', $validateAttributes);
array_splice($validateAttributes, $key, 1);

AJAX validation be fixed!!! But in registration form after submit mark login red and show error _Something went wrong_

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

hmmm, registration worked with my changes. but you have error with check email when insert DB record. I'll see it tomorrow if you do not get better.
TIP: may be in form validation you check email as email confirmed? But in insert check email in excisting email and does not check for this mail confirmed? In form check validation ok, on insert error.
P.S. Sorry for my english:)

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

see activerecord insert function. in if !$this->validate($attributes) always true. see model validate function it execute function hasErrors and problem here.

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

i found problem.
how to reproduce:

  1. register user
  2. try register another user but with the same email
    You got message "Something went wrong". if debug you see E-mail "[email protected]" has already been taken
    Model use yii\validators\UniqueValidator for email. It's wrong. While email is not confirmed, you can register any number of users with the same email.
    And I forgot to say, i make registration form with email, but without confirmation. How to make after registration sent email with confirmation?
    Hacker could register a user with a victim email. Owner (victim) with this email no longer be able to register on the site.

from user-management.

webvimark avatar webvimark commented on July 28, 2024

I don't know how you implement it in your custom registration form, but you can check how I implemented email validation in User class.

    /**
     * Check that there is no such confirmed E-mail in the system
     */
    public function validateEmailConfirmedUnique()
    {
        if ( $this->email )
        {
            $exists = User::findOne([
                'email'           => $this->email,
                'email_confirmed' => 1,
            ]);

            if ( $exists AND $exists->id != $this->id )
            {
                $this->addError('email', UserManagementModule::t('front', 'This E-mail already exists'));
            }
        }
    }

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

Maybe i make reg form wrong. Please make exmaple (i ask it in #12)

from user-management.

TomskDiver avatar TomskDiver commented on July 28, 2024

I find solution. In User model you set
['email', 'unique'],
['email', 'validateEmailConfirmedUnique'],
first validation (unique) is not necessary (wrong)!

from user-management.

webvimark avatar webvimark commented on July 28, 2024

I've also started making example in https://github.com/webvimark/user-management/wiki/Registration-with-E-mail-as-login-and-required-confirmation (in progress - don't use as example yet).

So I'm closing issue and will leave feedback in in #12 when it's ready

from user-management.

donmedo2000 avatar donmedo2000 commented on July 28, 2024

Hi, I just had my first encounter with the captcha issue in webvimark user management module. @TomskDiver, you're right. the validation keeps returning []. Workaround is this
$validateAttributes = $model->attributes;
unset($validateAttributes['captcha']);
return ActiveForm::validate($model,$validateAttributes);

Change last line above to

return ActiveForm::validate($model,array_keys($validateAttributes));

from user-management.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.