Commit graph

90 commits

Author SHA1 Message Date
Johannes Löthberg
eb169d3b0b Only print no changes message if queries failed
This commit changes the messages printed when changing the accound
details so that it only prints that no changes were made if either the
account change SQL query or the account_set_ssh_keys call failed.

Reported-by: Alexis Chotard <alexis.horgix.chotard@gmail.com>
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-27 18:00:39 +02:00
Lukas Fleischer
b036b436aa Add support for multiple SSH public keys
Attaching more than one SSH public key to the same account is useful,
e.g. if one uses different machines to access the AUR SSH interface.
Multiple keys can now be specified by adding multiple lines to the text
area on the account edit form.

Implements FS#45469.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Acked-by: Leonidas Spyropoulos <artafinde@gmail.com>
2015-06-27 13:04:03 +02:00
Gordian Edenhofer
6395a5d5b8 Redirect at previous page after a successful login
After the user was authenticated a redirect to the site which
linked the user to the login page is done. This fixes FS#32481.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-06-27 13:04:03 +02:00
Lukas Fleischer
86352459ab Allow for resetting the SSH public key
Use NULL instead of an empty string if the SSH public key field is left
empty. Additionally, do not check for duplicate keys in that case.

Fixes FS#45109.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
2015-05-31 19:16:31 +02:00
Lukas Fleischer
253e76d8cc Add support for adding SSH public keys to profiles
Users can now add an SSH public key on the account edit page. This will
later be used to authenticate users via SSH.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-12-27 12:42:12 +01:00
Lukas Fleischer
5ebf534ba7 Avoid double slashes in notification email body
Refactor some of the URI generation code to avoid double slashes in
absolute URIs.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-12-13 15:28:54 +01:00
Lukas Fleischer
e0c1caece5 Remove duplicate slash in the password reset URL
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-11-21 11:43:31 +01:00
Lukas Fleischer
76343fb915 Use an INI-style configuration file
Replace web/lib/config.inc.php with an INI-style configuration file.
This allows us to get rid of several globals and makes it easier to use
the same configuration file in external scripts.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-10-24 10:03:54 +02:00
Lukas Fleischer
01fed360c2 Use proper email address in send_resetkey()
Fixes FS#41860.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-10-10 10:20:57 +02:00
Lukas Fleischer
237a4570e2 Add PCRE_DOLLAR_ENDONLY to preg_match()
When using preg_match() to check for a match that starts at the
beginning of the string and ends at the last character of the string, we
do not want to allow an additional newline character to sneak in.
Amongst other potential loopholes, adding the PCRE_DOLLAR_ENDONLY
modifier prevents users from registering with user names that end with a
newline character.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-08-06 00:00:33 +02:00
Balló György
92e827330c Count users in "Trusted User & Developer" group as TU
This reflects the changes in 3610f3c.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-08-02 15:25:46 +02:00
Lukas Fleischer
4b5f8da5be Suppress PHP notice in process_account_form()
Add a check to remove a notice which is displayed after registration
since commit 03c6304 (Rework permission handling, 2014-07-15).

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-29 14:39:10 +02:00
Lukas Fleischer
34aa226c66 Do not allow regular users to edit all accounts
Fixes a regression introduced in 03c6304 (Rework permission handling,
2014-07-15).

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-25 11:30:33 +02:00
Lukas Fleischer
f4ee1278e5 Clean up user references in user_delete()
Explicitly clean up all references before deleting a user.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-25 11:30:32 +02:00
Lukas Fleischer
3610f3c6a4 Add a new user group "Trusted User & Developer"
This group has full permissions on everything.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-15 22:58:57 +02:00
Lukas Fleischer
1b901616dc Disallow privileged users to use invalid user names
Prevent Trusted Users and developers from accidentally using a name that
contains invalid characters. Also, remove user_is_privileged() which is
no longer needed after this change.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-15 22:56:57 +02:00
Lukas Fleischer
03c6304e19 Rework permission handling
Add a new function has_credential() that checks whether the currently
logged in user is allowed to perform a given action. Moving all
permission handling to this central place makes adding new user groups
and adjusting permissions much more convenient.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-07-15 22:56:57 +02:00
Lukas Fleischer
5463bdeff6 acctfuncs.inc.php: Fix indentation
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-06-05 15:16:34 +02:00
Lukas Fleischer
1aec9f7124 acctfuncs.inc.php: Reduce nesting in several functions
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-06-05 15:12:10 +02:00
Lukas Fleischer
0a66f48aa1 Do not return "None" in user functions
Return null instead of the string "None" in username_from_id(),
uid_from_email() and uid_from_username().

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-06-05 15:12:10 +02:00
Lukas Fleischer
e018670607 Accept upper case letters in valid_username()
In commit 0722f46 (Simplify valid_user() and valid_username(),
2014-02-06), the conversion to lower case letters was unintentionally
removed and in consequence, names with upper case letters have been
rejected since then.

Instead of reintroducing the conversion, add the "i" modifier to the
regular expression validating the name to do case-insensitive pattern
matching.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-05-30 09:32:48 +02:00
Lukas Fleischer
d7f0b25e51 acctfuncs.inc.php: Fix typo
Replace a misplaced semicolon with the concatenation operator. This
makes the AUR insert proper Reply-to and From headers again when sending
password reset emails on registration.

Fixes a regression introduced in 94a4f59 (Set Content-type header when
sending UTF-8 mails, 2014-02-10).

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-05-22 21:08:47 +02:00
Lukas Fleischer
839bff3761 Use aur.archlinux.org in sender email addresses
Consistently use the following headers in notification emails:

    Reply-to: noreply@aur.archlinux.org
    From: notify@aur.achlinux.org

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-05-22 15:43:41 +02:00
Lukas Fleischer
02e7df7631 Be friendly to newly registered users
Use "Welcome to the Arch User Repository" instead of "AUR Password
Reset" as subject for the initial password reset email.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-05-22 15:43:41 +02:00
Lukas Fleischer
94a4f597ff Set Content-type header when sending UTF-8 mails
Fixes FS#38568.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-10 21:00:36 +01:00
Lukas Fleischer
16c3a86193 Use CRLF to separate headers in mail()
This is the correct delimiter for mail headers according to the PHP
documentation and RFC 2822.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-10 20:48:34 +01:00
Lukas Fleischer
8c07c091e8 Remove LastVoted column
This has been introduced by commit aae43d9 (started working on package
comments, 2005-03-05) but it seems to be of no practical use. Remove the
field to save some space.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-09 01:43:37 +01:00
Lukas Fleischer
0722f46c6e Simplify valid_user() and valid_username()
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-06 18:59:40 +01:00
Lukas Fleischer
34447e7233 acctfuncs.inc.php: Fix comment style
* Use C-style comments (/* */) instead of #.
* Remove some superfluous comments and slightly reword others.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-06 16:32:31 +01:00
Lukas Fleischer
333ce08027 Sort last TU votes by vote and by user name
Instead of using a random secondary order, sort by the ID of the last
vote first, then by user name.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-02-01 17:38:58 +01:00
canyonknight
1bc78b9dff acctfuncs.inc.php: Allow translation of missing strings
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-01-20 15:41:17 +01:00
Lukas Fleischer
2276171b29 Only include current TUs in the last votes list
Do not show users that took part in past TU votes but no longer have TU
powers. Also, fix the sorting column while we're touching these lines.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-28 01:52:40 +02:00
Lukas Fleischer
86d2efaaa0 Exclude running votes from "Last Votes by TU"
Showing running votes potentially allows for tracking votes and
associating yes/no/abstain votes with specific TUs.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-27 10:52:38 +02:00
Lukas Fleischer
2dd3d04f45 Add "Last Votes by TU" list
This shows a list of all Trusted Users and the vote ID of the last
proposal each of the TUs voted on. This list is sorted by vote ID.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-26 17:34:31 +02:00
Lukas Fleischer
d41e40d9d6 Add a vote type to the TU proposal form
There are only four valid reasons for starting a TU vote, so instead of
letting the user choose a vote length, let her pick a reason and set
vote length and quorum based on that selection.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-22 17:48:18 +02:00
Lukas Fleischer
9ff082be25 Store the number of TUs when starting a vote
This will be used for automated calculation of vote participation later.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-22 17:47:51 +02:00
Lukas Fleischer
6844f6c1d2 Allow for setting an account's inactivity status
This adds a field to the users table and corresponding fields to the
account edit and display forms that allow for setting an (in-)activity
status.

This might turn out to be useful if a user is on vacation and can not
respond to update/orphan/deletion requests.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-22 17:43:13 +02:00
canyonknight
cf083cf9ba Remove superfluous search wrapper function
The search_accounts_form() wrapper function doesn't have any
arguments and only makes it unclear what is happening within
account.php

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-04-24 11:05:51 +02:00
Lukas Fleischer
cd59a313b4 Show hint if password is empty during login
A user might have an empty password due to two reasons:

* The user just created an account and needs to set an initial password.
* The password has been reset by the administrator.

In both cases, the user might be confused as to why the login does not
work. Add a message that helps users debug the issue in both cases.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-25 02:15:12 +01:00
canyonknight
cb91942595 Implement IP banning for user registration and user login
Adds a new is_ipbanned() function to determine whether the user
attempting to login or register for an account has their IP
address listed in the "Bans" table.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-24 22:12:17 +01:00
Lukas Fleischer
5660816ea0 Save last login IP address
Save the IP address used for the last login in the "Users" table. This
makes it a bit easier to create IP ban lists for spammers without
looking at web server logs.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-21 22:26:46 +01:00
Lukas Fleischer
de39a712b0 process_account_form(): Highlight errors
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-21 22:26:45 +01:00
Lukas Fleischer
97dd4b0f4d process_account_form(): Allow using empty passwords
If an empty password is passed during account registration, login for
the new user is disabled and a reset key is sent to the new user's
e-mail address so that they can set an initial password manually.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-19 14:03:34 +01:00
Lukas Fleischer
5d31bb2450 Move reset key submission to a separate function
This allows for reusing reset key submission for other things, such as
sending an initial password reset code during account registration.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-19 14:03:33 +01:00
canyonknight
cf2ab50b82 Remove checks before calling connection method
Large amount of boilerplate code that checks if a database
connection exists is useless now that the new connection method
automatically does the same check.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
4235d24039 Remove documentation references to database parameter
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
8d6c872297 Remove unnecessary database connection parameter from all functions
All functions now have a database connection method that will use
the same database connection. This imitates the functionality of
passing a database connection as an argument and makes it redundant.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
8e03e68d68 Add database wrapper class and new connection method
Uses the Singleton pattern to ensure all queries use the same
database connection that is released upon script completion.

All database connections should now be called with DB::connect() and
not db_connect().

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:37 +01:00
canyonknight
65e93f134f acctfuncs.inc.php: Change wording of account editing message
An error message is printed when the number of affected rows is
0 for an edited account. A count of 0 doesn't imply an error,
only that no changes were made in the database.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-01-30 09:25:30 +01:00
canyonknight
150b0f9f0a Clear a user's active sessions following account suspension
A suspended user can stay in active sessions. Introduce new function
delete_user_sessions to remove all open sessions for a specific user.
Allows suspensions to take effect immediately.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-01-30 09:25:30 +01:00