Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Make password reset email field case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkr committed Oct 14, 2016
1 parent 0061e87 commit 6207399
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
30 changes: 20 additions & 10 deletions synapse/storage/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,27 @@ def user_get_threepids(self, user_id):

@defer.inlineCallbacks
def get_user_id_by_threepid(self, medium, address):
ret = yield self._simple_select_one(
"user_threepids",
{
"medium": medium,
"address": address
},
['user_id'], True, 'get_user_id_by_threepid'
def f(txn):
sql = (
"SELECT user_id"
" FROM user_threepids"
" WHERE medium = ? AND LOWER(address) = LOWER(?)"
)
txn.execute(sql, (medium, address))
row = txn.fetchone()
if not row:
return None
if txn.rowcount > 1:
raise StoreError(500, "More than one row matched")
return {
"user_id": row[0]
}

res = yield self.runInteraction(
"get_user_id_by_threepid", f
)
if ret:
defer.returnValue(ret['user_id'])
defer.returnValue(None)

defer.returnValue(res)

def user_delete_threepids(self, user_id):
return self._simple_delete(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Copyright 2016 OpenMarket Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

CREATE INDEX user_threepids_medium_address on user_threepids (medium, LOWER(address));

0 comments on commit 6207399

Please sign in to comment.