Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed users.alias column, added option ('user_aliases')

to use email address from identities as username (#1488581)
  • Loading branch information...
commit 565c472918e7f9707cd8d7909ad5dbcc5a921fdf 1 parent 83121ec
@alecpl alecpl authored
View
2  CHANGELOG
@@ -1,6 +1,8 @@
CHANGELOG Roundcube Webmail
===========================
+- Removed users.alias column, added option ('user_aliases')
+ to use email address from identities as username (#1488581)
- Removed redundant cache.cache_id column (#1488528)
- Fix order of attachments in sent mail (#1488423)
- Don't show product version on login screen (can be enabled by config)
View
7 SQL/mssql.initial.sql
@@ -92,7 +92,6 @@ CREATE TABLE [dbo].[users] (
[user_id] [int] IDENTITY (1, 1) NOT NULL ,
[username] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
[mail_host] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
- [alias] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
[created] [datetime] NOT NULL ,
[last_login] [datetime] NULL ,
[language] [varchar] (5) COLLATE Latin1_General_CI_AI NULL ,
@@ -274,6 +273,8 @@ GO
CREATE INDEX [IX_identities_user_id] ON [dbo].[identities]([user_id]) ON [PRIMARY]
GO
+CREATE INDEX [IX_identities_email] ON [dbo].[identities]([email],[del]) ON [PRIMARY]
+GO
ALTER TABLE [dbo].[session] ADD
CONSTRAINT [DF_session_sess_id] DEFAULT ('') FOR [sess_id],
@@ -287,16 +288,12 @@ GO
ALTER TABLE [dbo].[users] ADD
CONSTRAINT [DF_users_username] DEFAULT ('') FOR [username],
CONSTRAINT [DF_users_mail_host] DEFAULT ('') FOR [mail_host],
- CONSTRAINT [DF_users_alias] DEFAULT ('') FOR [alias],
CONSTRAINT [DF_users_created] DEFAULT (getdate()) FOR [created]
GO
CREATE UNIQUE INDEX [IX_users_username] ON [dbo].[users]([username],[mail_host]) ON [PRIMARY]
GO
-CREATE INDEX [IX_users_alias] ON [dbo].[users]([alias]) ON [PRIMARY]
-GO
-
CREATE UNIQUE INDEX [IX_dictionary_user_language] ON [dbo].[dictionary]([user_id],[language]) ON [PRIMARY]
GO
View
9 SQL/mssql.upgrade.sql
@@ -261,4 +261,13 @@ ALTER TABLE [dbo].[contacts] ALTER COLUMN [email] [varchar] (8000) COLLATE Latin
GO
ALTER TABLE [dbo].[contacts] ADD CONSTRAINT [DF_contacts_email] DEFAULT ('') FOR [email]
GO
+
+-- Updates from version 0.8
+
+ALTER TABLE [dbo].[cache] DROP COLUMN [cache_id]
+GO
+ALTER TABLE [dbo].[users] DROP COLUMN [alias]
+GO
+CREATE INDEX [IX_identities_email] ON [dbo].[identities]([email],[del]) ON [PRIMARY]
+GO
View
7 SQL/mysql.initial.sql
@@ -22,14 +22,12 @@ CREATE TABLE `users` (
`user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`username` varchar(128) BINARY NOT NULL,
`mail_host` varchar(128) NOT NULL,
- `alias` varchar(128) BINARY NOT NULL,
`created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`last_login` datetime DEFAULT NULL,
`language` varchar(5),
`preferences` text,
PRIMARY KEY(`user_id`),
- UNIQUE `username` (`username`, `mail_host`),
- INDEX `alias_index` (`alias`)
+ UNIQUE `username` (`username`, `mail_host`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
@@ -156,7 +154,8 @@ CREATE TABLE `identities` (
PRIMARY KEY(`identity_id`),
CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
- INDEX `user_identities_index` (`user_id`, `del`)
+ INDEX `user_identities_index` (`user_id`, `del`),
+ INDEX `email_identities_index` (`email`, `del`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
View
4 SQL/mysql.update.sql
@@ -242,4 +242,6 @@ ALTER TABLE `searches` ALTER `user_id` DROP DEFAULT;
-- Updates from version 0.8
-ALTER TABLE cache DROP COLUMN cache_id;
+ALTER TABLE `cache` DROP COLUMN `cache_id`;
+ALTER TABLE `users` DROP COLUMN `alias`;
+ALTER TABLE `identities` ADD INDEX `email_identities_index` (`email`, `del`);
View
4 SQL/postgres.initial.sql
@@ -20,7 +20,6 @@ CREATE TABLE users (
user_id integer DEFAULT nextval('user_ids'::text) PRIMARY KEY,
username varchar(128) DEFAULT '' NOT NULL,
mail_host varchar(128) DEFAULT '' NOT NULL,
- alias varchar(128) DEFAULT '' NOT NULL,
created timestamp with time zone DEFAULT now() NOT NULL,
last_login timestamp with time zone DEFAULT NULL,
"language" varchar(5),
@@ -28,9 +27,7 @@ CREATE TABLE users (
CONSTRAINT users_username_key UNIQUE (username, mail_host)
);
-CREATE INDEX users_alias_id_idx ON users (alias);
-
--
-- Table "session"
-- Name: session; Type: TABLE; Schema: public; Owner: postgres
@@ -81,6 +78,7 @@ CREATE TABLE identities (
);
CREATE INDEX identities_user_id_idx ON identities (user_id, del);
+CREATE INDEX identities_email_idx ON identities (email, del);
--
View
3  SQL/postgres.update.sql
@@ -180,3 +180,6 @@ ALTER TABLE contacts ALTER email TYPE text;
ALTER TABLE cache DROP COLUMN cache_id;
DROP SEQUENCE cache_ids;
+
+ALTER TABLE users DROP COLUMN alias;
+CREATE INDEX identities_email_idx ON identities (email, del);
View
3  SQL/sqlite.initial.sql
@@ -80,6 +80,7 @@ CREATE TABLE identities (
);
CREATE INDEX ix_identities_user_id ON identities(user_id, del);
+CREATE INDEX ix_identities_email ON identities(email, del);
-- --------------------------------------------------------
@@ -92,7 +93,6 @@ CREATE TABLE users (
user_id integer NOT NULL PRIMARY KEY,
username varchar(128) NOT NULL default '',
mail_host varchar(128) NOT NULL default '',
- alias varchar(128) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
last_login datetime DEFAULT NULL,
language varchar(5),
@@ -100,7 +100,6 @@ CREATE TABLE users (
);
CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host);
-CREATE INDEX ix_users_alias ON users(alias);
-- --------------------------------------------------------
View
32 SQL/sqlite.update.sql
@@ -346,3 +346,35 @@ CREATE TABLE cache (
CREATE INDEX ix_cache_user_cache_key ON cache(user_id, cache_key);
CREATE INDEX ix_cache_created ON cache(created);
+
+CREATE TABLE tmp_users (
+ user_id integer NOT NULL PRIMARY KEY,
+ username varchar(128) NOT NULL default '',
+ mail_host varchar(128) NOT NULL default '',
+ created datetime NOT NULL default '0000-00-00 00:00:00',
+ last_login datetime DEFAULT NULL,
+ language varchar(5),
+ preferences text NOT NULL default ''
+);
+
+INSERT INTO tmp_users (user_id, username, mail_host, created, last_login, language, preferences)
+ SELECT user_id, username, mail_host, created, last_login, language, preferences FROM users;
+
+DROP TABLE users;
+
+CREATE TABLE users (
+ user_id integer NOT NULL PRIMARY KEY,
+ username varchar(128) NOT NULL default '',
+ mail_host varchar(128) NOT NULL default '',
+ created datetime NOT NULL default '0000-00-00 00:00:00',
+ last_login datetime DEFAULT NULL,
+ language varchar(5),
+ preferences text NOT NULL default ''
+);
+
+INSERT INTO users (user_id, username, mail_host, created, last_login, language, preferences)
+ SELECT user_id, username, mail_host, created, last_login, language, preferences FROM tmp_users;
+
+CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host);
+
+CREATE INDEX ix_identities_email ON identities(email, del);
View
3  config/main.inc.php.dist
@@ -195,6 +195,9 @@ $rcmail_config['skin_logo'] = null;
// set to false if only registered users can use this service
$rcmail_config['auto_create_user'] = true;
+// Enables possibility to log in using email address from user identities
+$rcmail_config['user_aliases'] = false;
+
// use this folder to store log files (must be writeable for apache user)
// This is used by the 'file' log driver.
$rcmail_config['log_dir'] = 'logs/';
View
19 program/include/rcube_user.php
@@ -397,15 +397,22 @@ function reset()
*/
static function query($user, $host)
{
- $dbh = rcube::get_instance()->get_dbh();
+ $dbh = rcube::get_instance()->get_dbh();
+ $config = rcube::get_instance()->config;
// query for matching user name
- $query = "SELECT * FROM ".$dbh->table_name('users')." WHERE mail_host = ? AND %s = ?";
- $sql_result = $dbh->query(sprintf($query, 'username'), $host, $user);
+ $sql_result = $dbh->query("SELECT * FROM " . $dbh->table_name('users')
+ ." WHERE mail_host = ? AND username = ?", $host, $user);
+
+ $sql_arr = $dbh->fetch_assoc($sql_result);
+
+ // username not found, try aliases from identities
+ if (empty($sql_arr) && $config->get('user_aliases') && strpos($user, '@')) {
+ $sql_result = $dbh->limitquery("SELECT u.*"
+ ." FROM " . $dbh->table_name('users') . " u"
+ ." JOIN " . $dbh->table_name('identities') . " i ON (i.user_id = u.user_id)"
+ ." WHERE email = ? AND del <> 1", 0, 1, $user);
- // query for matching alias
- if (!($sql_arr = $dbh->fetch_assoc($sql_result))) {
- $sql_result = $dbh->query(sprintf($query, 'alias'), $host, $user);
$sql_arr = $dbh->fetch_assoc($sql_result);
}
Please sign in to comment.
Something went wrong with that request. Please try again.