Repository: fossasia/open-event-server

Issue:
Unable to login to the Admin Panel.
**Description:**
When we try to login to admin panel, even if the credentials belong to super-admin, it returns "Credential incorrect"

**Steps to reproduce the behavior:**
1. Go to 127.0.0.1:5000/admin
2. Enter the admin credentials
3. Click on login button
4. See error "Credential incorrect"

**Expected Behaviour:**
It should login the user to the admin panel if credentials are correct and the user is an admin.

**Screenshots**
![error](https://user-images.githubusercontent.com/32808710/52912510-5d3b4180-32d8-11e9-93e6-86843c8f6fb4.png)



Discussion:
Will work on this and fix it up.

On Sun, 17 Feb 2019 at 5:21 PM, Divyam Goel <notifications@github.com>
wrote:

> *Description:*
> When we try to login to admin panel, even if the credentials belong to
> super-admin, it returns "Credential incorrect"
>
> *Steps to reproduce the behavior:*
>
>    1. Go to 127.0.0.1:5000/admin
>    2. Enter the admin credentials
>    3. Click on login button
>    4. See error "Credential incorrect"
>
> *Expected Behaviour:*
> It should login the user to the admin panel if credentials are correct and
> the user is an admin.
>
> *Screenshots*
> [image: error]
> <https://user-images.githubusercontent.com/32808710/52912510-5d3b4180-32d8-11e9-93e6-86843c8f6fb4.png>
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/fossasia/open-event-server/issues/5614>, or mute the
> thread
> <https://github.com/notifications/unsubscribe-auth/AYB6WxbdYH_bFukze81cTMSgJ19kLJHUks5vOUJPgaJpZM4a_hFU>
> .
>

@mrsaicharan1  I wanted to work on this issue.
Go ahead :)

On Sun, 17 Feb 2019 at 5:26 PM, saicharan reddy <saicharan.reddy1@gmail.com>
wrote:

> Will work on this and fix it up.
>
> On Sun, 17 Feb 2019 at 5:21 PM, Divyam Goel <notifications@github.com>
> wrote:
>
>> *Description:*
>> When we try to login to admin panel, even if the credentials belong to
>> super-admin, it returns "Credential incorrect"
>>
>> *Steps to reproduce the behavior:*
>>
>>    1. Go to 127.0.0.1:5000/admin
>>    2. Enter the admin credentials
>>    3. Click on login button
>>    4. See error "Credential incorrect"
>>
>> *Expected Behaviour:*
>> It should login the user to the admin panel if credentials are correct
>> and the user is an admin.
>>
>> *Screenshots*
>> [image: error]
>> <https://user-images.githubusercontent.com/32808710/52912510-5d3b4180-32d8-11e9-93e6-86843c8f6fb4.png>
>>
>> —
>> You are receiving this because you are subscribed to this thread.
>> Reply to this email directly, view it on GitHub
>> <https://github.com/fossasia/open-event-server/issues/5614>, or mute the
>> thread
>> <https://github.com/notifications/unsubscribe-auth/AYB6WxbdYH_bFukze81cTMSgJ19kLJHUks5vOUJPgaJpZM4a_hFU>
>> .
>>
>


Resolving patch:
diff --git a/app/views/__init__.py b/app/views/__init__.py
--- a/app/views/__init__.py
+++ b/app/views/__init__.py
@@ -3,7 +3,6 @@
 from flask import url_for, redirect, Blueprint, request, make_response
 from flask_admin import Admin, AdminIndexView, expose, helpers as admin_helpers
 from flask_admin.contrib.sqla import ModelView
-from flask_scrypt import generate_password_hash
 from wtforms import form, fields, validators
 
 from app.models import db
@@ -34,7 +33,7 @@ def validate_login(self, field):
         if user is None:
             raise validators.ValidationError('User does not exist.')
 
-        if user.password != generate_password_hash(self.password.data, user.salt):
+        if not user.is_correct_password(self.password.data):
             raise validators.ValidationError('Credentials incorrect.')
 
         if not user.is_admin and not user.is_super_admin:


Test patch: