130 Commits

Author SHA1 Message Date
Christopher Allan Webber
201ac38895 Fixing import error after merge of basic_auth branch.
This commit sponsored by geoffrey jost.  Thank you!
2013-09-19 18:02:43 -05:00
Christopher Allan Webber
74ae6fb0b6 Merge remote-tracking branch 'refs/remotes/rodney757/auth_refactor'
Conflicts:
	mediagoblin/auth/views.py
	mediagoblin/edit/forms.py
	mediagoblin/templates/mediagoblin/edit/edit_account.html
2013-09-19 16:04:23 -05:00
Rodney Ewing
dd57c6c5e5 didn't remove form.new_email when change email was moved to its own view 2013-08-31 13:45:58 -07:00
Christopher Allan Webber
6c3d383bbb Merge remote-tracking branch 'refs/remotes/rodney757/email' 2013-08-25 13:23:27 -05:00
Rodney Ewing
5a6e4e1307 check for form.password in the off chance that a user is logged in and the server switches the authentication method from basic_auth to openid. 2013-08-20 08:25:45 -07:00
Rodney Ewing
402f436011 maybe have change password and email on same page 2013-08-20 08:25:45 -07:00
Rodney Ewing
93d805ad6b add user prefrence for insite notifications 2013-08-20 08:10:50 -07:00
Rodney Ewing
af665c4eb9 moved change_pass to basic_auth and fixed some typos with the moving of forgot pass 2013-08-16 10:28:48 -07:00
Rodney Ewing
44082b12d8 Patch by Strum. Ticket #451 - Convert all mongokit style .find, .find_one, .one calls over to SQLAlchemy queries 2013-07-11 14:17:50 -07:00
Rodney Ewing
5adb906a0a merge --squash openid branch to take care of a false merge commit in the
basic_auth branch that openid is forked from

Commits squashed together (in reverse chronological order):
 - do the label thing only for boolean fields
 - made edit_account to autofocus on the first field
 - added feature to render_divs where if field.label == '' then it
   will render form.description the same a render_label
 - added allow_registration check
 - refactored create_user
 - removed verification_key from create_user
 - removed get_user from openid
 - cleanup after removing openid from template_env.globals
 - fix for werkzueg 0.9.1
 - cleanup after merge
 - more tests
 - restored openid extra_validation just for safety
 - tests for openid
 - deleted openid extra_validation
 - passed next parameter in session for openid
 - fixed a bug that was deleting the messages
 - implemented openid store using sqlalchemy
 - ask openid provider for 'nickname' to prefill username in registration form
 - refactored delete openid url to work with generic urls such as
   google and to not allow a user to delete a url if it is there only
   one and they don't have a pw
 - refactored login to register user workflow, which fixed a problem
   where the 'or register with a password link' wasn't showing up when
   the finish_login view called the register view because there wasn't
   any redirect.
 - added the ability to remove openid's
 - added the ability to add openids to an existing account
 - refactored start_login and finish_login views
 - modified edit_account.html to use render_divs
 - modified gmg/edit/views to behave appropriatly if no password
   authentication is enabled. moved the update email stuff to it's own
   funtion to make edit_account view cleaner. edit_account now
   modifies the form depending on the plugins.
 - minor typos
 - added retrieving email from openid provider
 - moved allow_registration check to a decorator
 - moved check if auth is enabled to a decorator
 - changed openid user registration to go through login first
 - cleanup after merge
 - modified verification emails to use itsdangerous tokens
 - added error handling on bad token, fixed route, and added tests
 - added support for user to change email address
 - added link to login view openid/password in login template
 - updated openid get_user function
 - modified get_user function to take kwargs instead of username
 - no need for user might be email kwarg in check_login_simple
 - added gen_password_hash and check_password functions to auth/__init__
 - added focus to form input
 - made imports fully qualified
 - modified basic_auth.check_login to check that the user has a pw_hash first
 - changed occurances of form.data['whatever'] to form.whatever.data
 - convert tabs to spaces in register template, remove unsed
   templates, and fixed trans tags in templates
 - in process of openid login. it works, but needs major imporvements
 - make password field required in basic_auth form
 - check if password field present in basic_auth create_user
 - modified openid create_user function
 - modified models based on Elronds suggestions
 - changed register form action to a variable to be passed in by the
   view using the template
 - openid plugin v0, still need to authenticate via openid.
 - added a register_user function to be able to use in a plugin's
   register view, and modified auth/views.register to redirect to
   openid/register if appropriate.
 - Modified basic_auth plugin to work with modified auth plugin
   hooks. Added context variables. Removed basic_auth/tools which was
   previously renamed to basic_auth/lib.
 - modified auth/__init__ hooks to work better with multiple
   plugins. Removed auth/lib.py. And added a basic_extra_verification
   function that all plugins will use.
 - added models and migrations for openid plugin
2013-07-03 13:49:16 -05:00
Rodney Ewing
6174169786 cleanup after merge 2013-06-25 13:43:33 -07:00
Rodney Ewing
af4414a85f Merge remote-tracking branch 'upstream/master' into auth
Conflicts:
	mediagoblin/app.py
	mediagoblin/auth/forms.py
	mediagoblin/auth/tools.py
	mediagoblin/db/migrations.py
	mediagoblin/db/models.py
	mediagoblin/edit/views.py
	mediagoblin/plugins/basic_auth/tools.py
	mediagoblin/tests/test_edit.py
2013-06-25 13:37:21 -07:00
Christopher Allan Webber
f7698af1c1 Removing the "enter your password to change your email" bit.
A good idea, though it feels fairly clumsy in the form, and I think if
you're logged in you can already sabotage the user pretty well.

This commit sponsored by Sergey Matveev.  Thanks!
2013-06-21 17:24:33 -05:00
Rodney Ewing
a90b350f71 send_verification_email was moved to auth/tools 2013-05-29 13:19:36 -07:00
Rodney Ewing
f670f48ddd form is already validated, no need to validate again 2013-05-29 13:13:50 -07:00
Rodney Ewing
377db0e7ff added error handling on bad token, fixed route, and added tests 2013-05-24 18:16:12 -07:00
Rodney Ewing
89e1563f68 added support for user to change email address 2013-05-24 18:16:12 -07:00
Rodney Ewing
9008e09941 fixed failing tests after rebase 2013-05-24 16:52:50 -07:00
Rodney Ewing
9c2c9be79d moved bcrypt_gen_password_hash to basic_auth/tools and added gen_password_hash function to auth/__init__ 2013-05-24 16:52:48 -07:00
Rodney Ewing
d54cf48a33 moved bcrypt_check_password to basic_auth/tools from auth/lib 2013-05-24 16:52:48 -07:00
Rodney Ewing
39aa1db4d6 moved change pass to a seperate view and fixed issues 709 2013-05-20 14:28:43 -07:00
Elrond
2e6ee596ad Create redir_obj and use it around.
This is a shortcut function to redirect to the main page
for an object. Objects currently supported: media entries
and collections.

And go around and replace various places to use this.
2013-04-28 23:09:20 +02:00
Elrond
5ae0cbaa55 No lazy_* needed here; Add ReallyLazyProxy.__repr__.
One should use lazy_* only if you have a good reason.

This one found by our unit tests!

For example add_message adds the message to the session,
the session needs to be serialized (with json) and well,
LazyProxy is not serializable.

To aid in debugging, gave our ReallyLazyProxy a __repr__.
2013-04-25 14:31:29 +02:00
Aditi Mittal
665b9c420a Fix-bug-667-Use-lazy_pass_to_ugettext-for-forms. 2013-04-24 16:40:29 -05:00
Elrond
455fd36ff6 Use GenerateSlugMixin for collections.
Use the new way of generating slugs also for collections.
Also drop the dummy_db arg to check_collection_slug_used.
2013-04-06 16:53:04 +02:00
Hans Lo
dc03850b7a Use WTForms data field in edit/views.py 2013-03-27 23:56:20 -04:00
Elrond
954b407cf8 Use the media id for attachmemt editing.
And remove some stray white space from the output.
2013-02-24 12:36:07 +01:00
András Veres-Szentkirályi
596b3410db removed unused import cgi.FieldStorage 2013-02-22 22:24:29 +01:00
Sebastian Spaeth
066d49b2c1 user.get('moo') -> user.moo
User fields are always existent, so there is no need to .get() them,
just use them directly.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-22 22:18:08 +01:00
Christopher Allan Webber
79f7cfd900 Merge remote-tracking branch 'refs/remotes/spaetz/521_license_preference' into mergetest 2013-01-22 13:43:02 -06:00
Sebastian Spaeth
9e9d908325 Sanitize slug input on media edit
Previously we allowed EVERYTHING, even slashes as slug when editing the media.
Make sure we slugify the input to sanitize it.

(+ string formdata is unicode, so there is no need to convert it)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-18 21:24:19 +01:00
Mark Holmquist
dc4dfbde35 Add a license preference field
This feature is absolutely necessary. Now a user can simply define
their default license and quickly go through a form, as opposed to
stopping to click on the select and choosing the same option over
and over again.

Also added DB migration for the field, so that's working now, too.

Rebased by Sebastian and made the default value to be unicode.

Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 21:34:04 +01:00
Sebastian Spaeth
380f22b859 Allowing to delete a user account (#302)
Add a "Delete user account" template and link to it from the user
account settings page.

Create a delete_account function and fill in most blanks. We can now
successfully delete our own account.

Thanks to Elrond for catching a stray csrf_exempt in a previous iteration
of this patch.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-17 12:19:52 +01:00
Christopher Allan Webber
27aebe05a6 Merge remote-tracking branch 'refs/remotes/elrond/misc/use_media_id' 2013-01-16 11:06:22 -06:00
Sebastian Spaeth
65969d3fb7 Simplify check_media_slug_used
Remove the unused dummy_db argument and generally make the function
readable.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-15 14:49:50 +01:00
Elrond
461dd9717c Start to use the media_id in "admin" URLs.
We have a bunch of URLs that are more for internal use. At
least they're definitely not intended to be posted
somewhere for long term useage.

When those things affect a media, it's much better to
reference the media by its id. This can't change, ever.
This is better for races.
Like someone posting a comment while the owner
corrects a typo in the slug.
2013-01-11 21:48:03 +01:00
Sebastian Spaeth
abc4da2927 Enable /u/USERNAME/edit/ pattern #588
Transition from the inconsistent /edit/profile/?username=FOO to
the nicer /u/FOO/edit/. The old pattern will still work and
redirects to the new URL.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2013-01-09 09:56:53 +01:00
Sebastian Spaeth
cfa922295e Convert return HttpException to raise HttpException
controllers (view function) raise HttpException's and do not return them.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-23 11:58:51 +01:00
Sebastian Spaeth
950124e640 webob.HTTPFound --> MG.tools.redirect
Transition away from webob.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 08:11:40 +01:00
Sebastian Spaeth
62d14bf50b Transition webob.HttpForbidden to webob's exceptions Forbidden
Also the BadRequest exception.
2012-12-21 08:11:40 +01:00
Sebastian Spaeth
5c2b84869f Move DBModel._id -> DBModel.id
We were refering to model._id in most of the code base as this is
what Mongo uses. However, each use of _id required a) fixup of queries:
e.g. what we did in our find() and find_one() functions moving all
'_id' to 'id'. It also required using AliasFields to make the ._id
attribute available. This all means lots of superfluous fixing and
transitioning in a SQL world.

It will also not work in the long run. Much newer code already refers
to the objects by model.id (e.g. in the oauth plugin), which will break
with Mongo. So let's be honest, rip out the _id mongoism and live with
.id as the one canonical way to address objects.

This commit modifies all users and providers of model._id to use
model.id instead. This patch works with or without Mongo removed first,
but will break Mongo usage (even more than before)

I have not bothered to fixup db.mongo.* and db.sql.convert
(which converts from Mongo to SQL)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-21 00:30:48 +01:00
Elrond
32255ec015 Fix translations around.
This includes:
- Mark more strings for translation
- Don't mark html-only nonsense for translation
- Mark a better part for translation.
2012-12-03 16:52:35 +01:00
Joar Wandborg
c43f8c1d92 Fixed attachments 2012-10-23 01:10:46 +02:00
Joar Wandborg
111a609df5 Replaced all request.POST with request.form, ...
- Fixed error handling in OAuth plugin
- Changed request.POST file fields to request.files
2012-09-29 21:08:20 +02:00
Christopher Allan Webber
a648102890 Too much was marked for translation this gettext message.
Thanks for catching AVRS!
2012-09-24 14:00:34 -05:00
Aaron Williamson
b5a64f7884 Removed unnecessary reference to may_edit_collection in edit views.py 2012-09-18 18:10:36 +02:00
Aaron Williamson
be5be1154f Added basic collection functionality 2012-09-18 18:10:36 +02:00
Joar Wandborg
825b136227 Added some security checks to attachment upload, it's still not
waterproof.
2012-06-24 21:29:07 +02:00
Joar Wandborg
879ff4bde6 Merge remote-tracking branch 'is_derek/bug405_email_notifications_for_comments' into notifications-merge
Conflicts:
	mediagoblin/db/mongo/migrations.py
2012-06-10 15:53:46 +02:00
Will Kahn-Greene
a855e92a98 Fix problems from pyflakes output 2012-06-03 15:53:34 -04:00