Mercurial Hosting > freedit
comparison src/lib/User.luan @ 57:169ac5fdb320
add change email
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Mon, 28 Nov 2022 23:47:19 -0700 |
| parents | 7ce54f6d93f2 |
| children | 31c895b73bd0 |
comparison
equal
deleted
inserted
replaced
| 56:7ce54f6d93f2 | 57:169ac5fdb320 |
|---|---|
| 37 id = doc.id | 37 id = doc.id |
| 38 email = doc.user_email | 38 email = doc.user_email |
| 39 password = doc.password | 39 password = doc.password |
| 40 name = doc.user_name | 40 name = doc.user_name |
| 41 created = doc.created | 41 created = doc.created |
| 42 hidden_password = doc.hidden_password | |
| 42 } | 43 } |
| 43 set_local_only(users_by_id,user.id,user) | 44 set_local_only(users_by_id,user.id,user) |
| 44 return user | 45 return user |
| 45 end | 46 end |
| 46 | 47 |
| 51 id = user.id | 52 id = user.id |
| 52 user_email = email | 53 user_email = email |
| 53 password = user.password | 54 password = user.password |
| 54 user_name = user.name | 55 user_name = user.name |
| 55 created = user.created or time_now() | 56 created = user.created or time_now() |
| 57 hidden_password = user.hidden_password | |
| 56 } | 58 } |
| 57 end | 59 end |
| 58 | 60 |
| 59 local metatable = {} | 61 local metatable = {} |
| 60 function metatable.__index(user,key) | 62 function metatable.__index(user,key) |
| 148 for _ in range(1,10) do | 150 for _ in range(1,10) do |
| 149 t[#t+1] = password_chars[random(n)] | 151 t[#t+1] = password_chars[random(n)] |
| 150 end | 152 end |
| 151 return concat(t) | 153 return concat(t) |
| 152 end | 154 end |
| 155 User.new_password = new_password | |
| 153 | 156 |
| 154 function User.get_or_create_by_email(email,change_password) | 157 function User.get_or_create_by_email(email,change_password) |
| 155 local user = User.get_by_email(email) | 158 local user = User.get_by_email(email) |
| 156 if user == nil then | 159 if user == nil then |
| 157 run_in_transaction( function() | 160 run_in_transaction( function() |
