Merge pull request #32 from ivandiazwm/master

Fix SMTP issues and add new step to installation process
This commit is contained in:
Ivan Diaz 2017-06-14 18:26:42 -03:00 committed by GitHub
commit 83c6330f73
42 changed files with 448 additions and 103 deletions

View File

@ -46,5 +46,12 @@ export default {
data: {}
})
};
},
updateUserSystemSettings(payload) {
return {
type: 'UPDATE_USER_SYSTEM_SETTINGS',
payload: payload
};
}
};

View File

@ -57,8 +57,9 @@ import InstallStep1Language from 'app/install/install-step-1-language';
import InstallStep2Requirements from 'app/install/install-step-2-requirements';
import InstallStep3Database from 'app/install/install-step-3-database';
import InstallStep4UserSystem from 'app/install/install-step-4-user-system';
import InstallStep5Admin from 'app/install/install-step-5-admin';
import InstallStep6Completed from 'app/install/install-step-6-completed';
import InstallStep5Settings from 'app/install/install-step-5-settings';
import InstallStep6Admin from 'app/install/install-step-6-admin';
import InstallStep7Completed from 'app/install/install-step-7-completed';
export default (
<Router history={history}>
@ -93,8 +94,9 @@ export default (
<Route path="step-2" component={InstallStep2Requirements} />
<Route path="step-3" component={InstallStep3Database} />
<Route path="step-4" component={InstallStep4UserSystem} />
<Route path="step-5" component={InstallStep5Admin} />
<Route path="step-6" component={InstallStep6Completed} />
<Route path="step-5" component={InstallStep5Settings} />
<Route path="step-6" component={InstallStep6Admin} />
<Route path="step-7" component={InstallStep7Completed} />
</Route>
<Route path="admin">
<IndexRoute component={AdminLoginPage} />

View File

@ -14,6 +14,7 @@ const steps = [
'SERVER_REQUIREMENTS',
'DATABASE_CONFIGURATION',
'USER_SYSTEM',
'SYSTEM_SETTINGS',
'ADMIN_SETUP',
'COMPLETED'
];
@ -92,6 +93,8 @@ class InstallLayout extends React.Component {
return 4;
} else if(_.includes(pathname, 'step-6')) {
return 5;
} else if(_.includes(pathname, 'step-7')) {
return 6;
}
}
}

View File

@ -14,7 +14,7 @@ class InstallStep1Language extends React.Component {
render() {
return (
<div className="install-step-1">
<Header title={i18n('STEP_TITLE', {title: i18n('SELECT_LANGUAGE'), current: 1, total: 6})} description={i18n('STEP_1_DESCRIPTION')}/>
<Header title={i18n('STEP_TITLE', {title: i18n('SELECT_LANGUAGE'), current: 1, total: 7})} description={i18n('STEP_1_DESCRIPTION')}/>
<LanguageSelector {...this.getLanguageSelectorProps()} />
<div className="install-step-1__button">
<Button size="medium" type="secondary" onClick={() => history.push('/install/step-2')}>

View File

@ -30,7 +30,7 @@ class InstallStep2Requirements extends React.Component {
render() {
return (
<div className="install-step-2">
<Header title={i18n('STEP_TITLE', {title: i18n('SERVER_REQUIREMENTS'), current: 2, total: 6})} description={i18n('STEP_2_DESCRIPTION')}/>
<Header title={i18n('STEP_TITLE', {title: i18n('SERVER_REQUIREMENTS'), current: 2, total: 7})} description={i18n('STEP_2_DESCRIPTION')}/>
<div className="install-step-2__refresh">
<Button className="install-step-2__refresh-button" type="secondary" size="medium" onClick={this.retrieveRequirements.bind(this)}>
<Icon className="install-step-2__refresh-icon" name="refresh" /> {i18n('REFRESH')}

View File

@ -22,7 +22,7 @@ class InstallStep3Database extends React.Component {
render() {
return (
<div className="install-step-3">
<Header title={i18n('STEP_TITLE', {title: i18n('DATABASE_CONFIGURATION'), current: 3, total: 6})} description={i18n('STEP_3_DESCRIPTION')}/>
<Header title={i18n('STEP_TITLE', {title: i18n('DATABASE_CONFIGURATION'), current: 3, total: 7})} description={i18n('STEP_3_DESCRIPTION')}/>
{this.renderMessage()}
<Form loading={this.state.loading} onSubmit={this.onSubmit.bind(this)}>
<FormField name="dbHost" label={i18n('DATABASE_HOST')} fieldProps={{size: 'large'}} required/>

View File

@ -3,7 +3,7 @@ import { connect } from 'react-redux'
import history from 'lib-app/history';
import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call';
import ConfigActions from 'actions/config-actions';
import ToggleButton from 'app-components/toggle-button';
import Button from 'core-components/button';
@ -15,7 +15,6 @@ import SubmitButton from 'core-components/submit-button';
class InstallStep4UserSystem extends React.Component {
state = {
loading: false,
form: {
'user-system-enabled': true,
'registration': true
@ -25,8 +24,8 @@ class InstallStep4UserSystem extends React.Component {
render() {
return (
<div className="install-step-4">
<Header title={i18n('STEP_TITLE', {title: i18n('USER_SYSTEM'), current: 4, total: 6})} description={i18n('STEP_4_DESCRIPTION')}/>
<Form onSubmit={this.onSubmit.bind(this)} values={this.state.form} onChange={this.onChange.bind(this)} loading={this.state.loading}>
<Header title={i18n('STEP_TITLE', {title: i18n('USER_SYSTEM'), current: 4, total: 7})} description={i18n('STEP_4_DESCRIPTION')}/>
<Form onSubmit={this.onSubmit.bind(this)} values={this.state.form} onChange={this.onChange.bind(this)}>
<FormField name="user-system-enabled" label={i18n('ENABLE_USER_SYSTEM')} decorator={ToggleButton}/>
<FormField name="registration" label={i18n('ENABLE_USER_REGISTRATION')} decorator={ToggleButton} fieldProps={{disabled: this.isDisabled()}}/>
<div className="install-step-4__buttons">
@ -53,20 +52,12 @@ class InstallStep4UserSystem extends React.Component {
}
onSubmit(form) {
this.setState({
loading: true
}, () => API.call({
path: '/system/init-settings',
data: {
'language': this.props.language,
'user-system-enabled': form['user-system-enabled'] * 1,
'registration': form['registration'] * 1
}
}).then(() => this.setState({
loading: false
}, () => history.push('/install/step-5'))).catch(() => this.setState({
loading: false
})));
this.props.dispatch(ConfigActions.updateUserSystemSettings({
'user-system-enabled': form['user-system-enabled'] * 1,
'registration': form['registration'] * 1
}));
history.push('/install/step-5');
}
isDisabled() {
@ -74,7 +65,6 @@ class InstallStep4UserSystem extends React.Component {
}
}
export default connect((store) => {
return {
language: store.config.language

View File

@ -0,0 +1,134 @@
import React from 'react';
import _ from 'lodash';
import { connect } from 'react-redux'
import history from 'lib-app/history';
import i18n from 'lib-app/i18n';
import API from 'lib-app/api-call';
import Button from 'core-components/button';
import Header from 'core-components/header';
import Form from 'core-components/form';
import FormField from 'core-components/form-field';
import SubmitButton from 'core-components/submit-button';
import Message from 'core-components/message';
class InstallStep5Settings extends React.Component {
state = {
loading: false,
smtpConnection: null,
form: {},
error: false,
errorMessage: ''
};
render() {
return (
<div className="install-step-5">
<Header title={i18n('STEP_TITLE', {title: i18n('SYSTEM_SETTINGS'), current: 5, total: 7})} description={i18n('STEP_5_DESCRIPTION')}/>
{this.renderMessage()}
<Form loading={this.state.loading} onSubmit={this.onSubmit.bind(this)} value={this.state.form} onChange={(form) => this.setState({form})}>
<FormField name="title" label={i18n('TITLE')} fieldProps={{size: 'large'}} required/>
<FormField className="install-step-5__attachments-field" name="allow-attachments" label={i18n('ALLOW_FILE_ATTACHMENTS')} field="checkbox" fieldProps={{size: 'large'}}/>
<FormField name="no-reply-email" label={i18n('NOREPLY_EMAIL')} fieldProps={{size: 'large'}}/>
<div className="install-step-5__smtp-block">
<Header title={i18n('SMTP_SERVER')} description={i18n('SMTP_SERVER_DESCRIPTION')} />
<FormField name="smtp-host" label={i18n('SMTP_SERVER')} fieldProps={{size: 'large'}}/>
<FormField name="smtp-port" label={i18n('PORT')} fieldProps={{size: 'small'}}/>
<FormField name="smtp-user" label={i18n('SMTP_USER')} fieldProps={{size: 'large'}}/>
<FormField name="smtp-password" label={i18n('SMTP_PASSWORD')} fieldProps={{size: 'large', password: true}}/>
<Button className="install-step-5__test-connection" size="medium" onClick={this.onTestSMTPClick.bind(this)}>
{i18n('TEST_SMTP_CONNECTION')}
</Button>
{this.renderMessageSMTP()}
</div>
<div className="install-step-5__buttons">
<SubmitButton className="install-step-5__next" size="medium" type="secondary">{i18n('NEXT')}</SubmitButton>
<Button className="install-step-5__previous" size="medium" onClick={this.onPreviousClick.bind(this)}>{i18n('PREVIOUS')}</Button>
</div>
</Form>
</div>
);
}
renderMessage() {
let message = null;
if(this.state.error) {
message = (
<Message className="install-step-5__message" type="error">
{i18n('ERROR_UPDATING_SETTINGS')}: {this.state.errorMessage}
</Message>
);
}
return message;
}
renderMessageSMTP() {
let message = null;
if(this.state.smtpConnection !== null) {
if(this.state.smtpConnection) {
message = (
<Message className="install-step-5__smtp-message" type="success">
{i18n('SMTP_CONNECTION_SUCCESS')}
</Message>
);
} else {
message = (
<Message className="install-step-5__smtp-message" type="error">
{i18n('SMTP_CONNECTION_ERROR')}
</Message>
);
}
}
return message;
}
onTestSMTPClick(event) {
event.preventDefault();
API.call({
path: '/system/test-smtp',
data: this.state.form
}).then(() => this.setState({smtpConnection: true}))
.catch(() => this.setState({smtpConnection: false}));
}
onPreviousClick(event) {
event.preventDefault();
history.push('/install/step-4');
}
onSubmit(form) {
this.setState({
loading: true
}, () => {
API.call({
path: '/system/init-settings',
data: _.extend({}, form, {
'language': this.props.language,
'user-system-enabled': this.props['user-system-enabled'],
'registration': this.props['registration']
})
})
.then(() => history.push('/install/step-6'))
.catch(({message}) => this.setState({
loading: false,
error: true,
errorMessage: message
}));
});
}
}
export default connect((store) => {
return {
'user-system-enabled': store.config['user-system-enabled'],
'registration': store.config['registration'],
language: store.config.language
};
})(InstallStep5Settings);

View File

@ -0,0 +1,34 @@
@import "../../scss/vars";
.install-step-5 {
&__previous {
margin-right: 20px;
}
&__next {
float: left;
position: absolute;
margin-left: 230px;
min-width: 70px;
}
&__smtp-block {
text-align: center;
background-color: $very-light-grey;
padding: 30px;
margin-bottom: 30px;
.header__title {
font-size: $font-size--md;
}
}
&__attachments-field {
margin-bottom: 15px;
}
&__smtp-message {
margin-top: 30px;
}
}

View File

@ -10,7 +10,7 @@ import FormField from 'core-components/form-field';
import SubmitButton from 'core-components/submit-button';
import Message from 'core-components/message';
class InstallStep5Admin extends React.Component {
class InstallStep6Admin extends React.Component {
state = {
loading: false,
@ -20,15 +20,15 @@ class InstallStep5Admin extends React.Component {
render() {
return (
<div className="install-step-5">
<Header title={i18n('STEP_TITLE', {title: i18n('ADMIN_SETUP'), current: 5, total: 6})} description={i18n('STEP_5_DESCRIPTION')}/>
<div className="install-step-6">
<Header title={i18n('STEP_TITLE', {title: i18n('ADMIN_SETUP'), current: 6, total: 7})} description={i18n('STEP_6_DESCRIPTION')}/>
{this.renderMessage()}
<Form onSubmit={this.onSubmit.bind(this)}>
<FormField name="name" validation="NAME" label={i18n('ADMIN_NAME')} fieldProps={{size: 'large'}} required/>
<FormField name="email" validation="EMAIL" label={i18n('ADMIN_EMAIL')} fieldProps={{size: 'large'}} required/>
<FormField name="password" validation="PASSWORD" label={i18n('ADMIN_PASSWORD')} infoMessage={i18n('ADMIN_PASSWORD_DESCRIPTION')} fieldProps={{size: 'large', autoComplete: 'off'}} required/>
<div className="install-step-5__buttons">
<SubmitButton className="install-step-5__next" size="medium" type="secondary">{i18n('NEXT')}</SubmitButton>
<div className="install-step-6__buttons">
<SubmitButton className="install-step-6__next" size="medium" type="secondary">{i18n('NEXT')}</SubmitButton>
</div>
</Form>
</div>
@ -40,7 +40,7 @@ class InstallStep5Admin extends React.Component {
if(this.state.error) {
message = (
<Message className="install-step-5_message" type="error">
<Message className="install-step-6_message" type="error">
{i18n('ERROR_UPDATING_SETTINGS')}: {this.state.errorMessage}
</Message>
);
@ -57,7 +57,7 @@ class InstallStep5Admin extends React.Component {
path: '/system/init-admin',
data: form
})
.then(() => history.push('/install/step-6'))
.then(() => history.push('/install/step-7'))
.catch(({message}) => this.setState({
loading: false,
error: true,
@ -67,4 +67,4 @@ class InstallStep5Admin extends React.Component {
}
}
export default InstallStep5Admin;
export default InstallStep6Admin;

View File

@ -1,6 +1,6 @@
@import "../../scss/vars";
.install-step-5 {
.install-step-6 {
&__message {
margin-bottom: 20px;

View File

@ -7,7 +7,7 @@ import i18n from 'lib-app/i18n';
import Header from 'core-components/header';
import Message from 'core-components/message';
class InstallStep6Completed extends React.Component {
class InstallStep7Completed extends React.Component {
componentDidMount() {
store.dispatch(ConfigActions.init());
@ -19,8 +19,8 @@ class InstallStep6Completed extends React.Component {
render() {
return (
<div className="install-step-6">
<Header title={i18n('STEP_TITLE', {title: i18n('COMPLETED'), current: 6, total: 6})} description={i18n('STEP_6_DESCRIPTION')}/>
<div className="install-step-7">
<Header title={i18n('STEP_TITLE', {title: i18n('COMPLETED'), current: 7, total: 7})} description={i18n('STEP_7_DESCRIPTION')}/>
<Message title={i18n('INSTALLATION_COMPLETED')} type="success">
{i18n('INSTALLATION_COMPLETED_DESCRIPTION')}
</Message>
@ -29,4 +29,4 @@ class InstallStep6Completed extends React.Component {
}
}
export default InstallStep6Completed;
export default InstallStep7Completed;

View File

@ -224,6 +224,16 @@ module.exports = [
};
}
},
{
path: '/system/test-smtp',
time: 100,
response: function () {
return {
status: 'success',
data: {}
};
}
},
{
path: '/system/get-mail-templates',
time: 100,

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': '在這裡,您可以通過更改電子郵件或密碼來修改用戶。',
'ENABLE_USER_SYSTEM_DESCRIPTION': '啟用/禁用用戶系統的使用。如果你禁用它,所有的用戶將被刪除,但票將被保留。如果啟用,將創建現有票證的用戶。',
'CSV_DESCRIPTION': 'CSV文件必須有3列電子郵件密碼名稱。行數沒有限制。它將在文件中的每行中創建一個用戶。',
'SMTP_SERVER_DESCRIPTION': 'SMTP服务器允许应用程序发送邮件。 如果您没有配置OpenSupports将不会发送任何电子邮件。',
//ERRORS
'EMAIL_OR_PASSWORD': '電子郵件或密碼無效',
@ -355,6 +356,10 @@ export default {
'LEFT_EMPTY_DATABASE': '留空为自动创建数据库',
'REMEMBER_ME': '记住我',
'EMAIL_LOWERCASE': '电子邮件',
'PASSWORD_LOWERCASE': '密码'
'PASSWORD_LOWERCASE': '密码',
'SYSTEM_SETTINGS': '系统设置',
'TEST_SMTP_CONNECTION': '测试SMTP连接',
'SMTP_CONNECTION_SUCCESS': 'SMTP凭据有效',
'SMTP_CONNECTION_ERROR': '无法连接到SMTP服务器'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'Hier können Sie Ihren Benutzer bearbeiten, indem Sie Ihre E-Mail oder Ihr Passwort ändern.',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'Aktivieren / deaktivieren Sie die Verwendung eines Benutzersystems. Wenn du es deaktivierst, werden alle Benutzer gelöscht, aber die Tickets werden gehalten. Wenn Sie es aktivieren, werden die Benutzer der vorhandenen Tickets erstellt.',
'CSV_DESCRIPTION': 'Die CSV-Datei muss 3 Spalten haben: E-Mail, Passwort, Name. Es gibt kein Limit in Zeilenzahl. Es wird ein Benutzer pro Zeile in der Datei erstellt.',
'SMTP_SERVER_DESCRIPTION': 'Die Konfiguration des SMTP-Servers ermöglicht es der Software, Mails zu senden. Wenn Sie es nicht konfigurieren, werden keine E-Mails von OpenSupports gesendet.',
//ERRORS
'EMAIL_OR_PASSWORD': 'E-Mail oder Passwort ungültig',
@ -355,5 +356,9 @@ export default {
'LEFT_EMPTY_DATABASE': 'Leer leer für die automatische Datenbankerstellung',
'REMEMBER_ME': 'Merken',
'EMAIL_LOWERCASE': 'Email',
'PASSWORD_LOWERCASE': 'Passwort'
'PASSWORD_LOWERCASE': 'Passwort',
'SYSTEM_SETTINGS': 'System settings',
'TEST_SMTP_CONNECTION': 'SMTP-Verbindung testen',
'SMTP_CONNECTION_SUCCESS': 'SMTP-Anmeldeinformationen sind gültig.',
'SMTP_CONNECTION_ERROR': 'Kann keine Verbindung zum SMTP-Server herstellen.'
};

View File

@ -239,8 +239,9 @@ export default {
'STEP_2_DESCRIPTION': 'Here are listed the requirements for running OpenSupports. Please make sure that all requirements are satisfied.',
'STEP_3_DESCRIPTION': 'Please fill the MySQL database configuration.',
'STEP_4_DESCRIPTION': 'Please select your user system preferences.',
'STEP_5_DESCRIPTION': 'Please configure the administrator account.',
'STEP_6_DESCRIPTION': 'Installation is completed.',
'STEP_5_DESCRIPTION': 'Please select your general system preferences.',
'STEP_6_DESCRIPTION': 'Please configure the administrator account.',
'STEP_7_DESCRIPTION': 'Installation is completed.',
//VIEW DESCRIPTIONS
'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.',
@ -285,6 +286,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'Here you can edit your user by changing your email or your password.',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'Enable/disable the use of an user system. If you disable it, all users will be deleted but the tickets will be kept. If you enable it, the users of existent tickets will be created.',
'CSV_DESCRIPTION': 'The CSV file must have 3 columns: email, password, name. There is no limit in row count. It will be created one user per row in the file.',
'SMTP_SERVER_DESCRIPTION': 'The configuration of the SMTP server allows the application to send mails. If you do not configure it, no emails will be sent by OpenSupports.',
//ERRORS
'EMAIL_OR_PASSWORD': 'Email or password invalid',
@ -355,5 +357,9 @@ export default {
'LEFT_EMPTY_DATABASE': 'Left empty for automatic database creation',
'REMEMBER_ME': 'Remember me',
'EMAIL_LOWERCASE': 'email',
'PASSWORD_LOWERCASE': 'password'
'PASSWORD_LOWERCASE': 'password',
'SYSTEM_SETTINGS': 'System settings',
'TEST_SMTP_CONNECTION': 'Test SMTP connection',
'SMTP_CONNECTION_SUCCESS': 'SMTP credentials are valid.',
'SMTP_CONNECTION_ERROR': 'Can\'t connect to SMTP server.'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'Aquí puedes editar tu usuario cambiando tu correo electrónico o tu contraseña.',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'Habilitar/Deshabilitar el uso de un sistema de usuario. Si lo deshabilitas, todos los usuarios serán eliminados pero los tickets serán guardados. Si lo habilitas, se crearán los usuarios de los tickets existentes.',
'CSV_DESCRIPTION': 'El archivo CSV debe tener 3 columnas: correo electrónico, contraseña, nombre. No hay límite en el recuento de filas. Se creará un usuario por fila en el archivo.',
'SMTP_SERVER_DESCRIPTION': 'La configuracion de SMTP permite que la applicacion mande emails. Si no es configurado, ningún mail sera enviado OpenSupports.',
//ERRORS
'EMAIL_OR_PASSWORD': 'Email o contraseña inválida',
@ -355,5 +356,8 @@ export default {
'LEFT_EMPTY_DATABASE': 'Dejar vacío para la creación automática de bases de datos',
'REMEMBER_ME': 'Recordarme',
'EMAIL_LOWERCASE': 'email',
'PASSWORD_LOWERCASE': 'contraseña'
'PASSWORD_LOWERCASE': 'contraseña',
'TEST_SMTP_CONNECTION': 'Probar conexion de SMTP',
'SMTP_CONNECTION_SUCCESS': 'La credenciales de SMTP son correctas.',
'SMTP_CONNECTION_ERROR': 'No es posible conectarse al servidor de SMTP.'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'Ici, vous pouvez modifier votre utilisateur en changeant votre adresse e-mail ou votre mot de passe.',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'Activer / désactiver l\'utilisation d\'un système utilisateur. Si vous le désactivez, tous les utilisateurs seront supprimés, mais les tickets seront conservés. Si vous l\'activez, les utilisateurs des tickets existants seront créés.',
'CSV_DESCRIPTION': 'Le fichier CSV doit comporter 3 colonnes: email, mot de passe, nom. Il n\'y a pas de limite dans le nombre de lignes. Il sera créé un utilisateur par ligne dans le fichier.',
'SMTP_SERVER_DESCRIPTION': 'La configuration du serveur SMTP permet à l\'application d\'envoyer des mails. Si vous ne le configurez pas, aucun service d\'email ne sera envoyé par OpenSupports.',
//ERRORS
'EMAIL_OR_PASSWORD': 'E-mail ou mot de passe invalide',
@ -355,5 +356,8 @@ export default {
'LEFT_EMPTY_DATABASE': 'Laisser vide pour la création automatique de la base de données',
'REMEMBER_ME': 'Se souvenir de moi',
'EMAIL_LOWERCASE': 'email',
'PASSWORD_LOWERCASE': 'mot de passe'
'PASSWORD_LOWERCASE': 'mot de passe',
'TEST_SMTP_CONNECTION': 'Test de connexion SMTP',
'SMTP_CONNECTION_SUCCESS': 'Les informations d\'identification SMTP sont valides.',
'SMTP_CONNECTION_ERROR': 'Ne peut pas se connecter au serveur SMTP.'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'यहां आप अपना ईमेल या अपना पासवर्ड बदलकर अपना उपयोगकर्ता संपादित कर सकते हैं।',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'किसी उपयोगकर्ता सिस्टम के उपयोग को सक्षम / अक्षम करें यदि आप इसे अक्षम करते हैं, तो सभी उपयोगकर्ताओं को हटा दिया जाएगा लेकिन टिकट को रखा जाएगा। यदि आप इसे सक्षम करते हैं, तो विद्यमान टिकट के उपयोगकर्ता बनाए जाएंगे',
'CSV_DESCRIPTION': 'सीएसवी फ़ाइल में 3 कॉलम होना चाहिए: ईमेल, पासवर्ड, नाम। पंक्ति गणना में कोई सीमा नहीं है फ़ाइल में प्रति पंक्ति एक उपयोगकर्ता बनाया जाएगा।',
'SMTP_SERVER_DESCRIPTION': 'एसएमटीपी सर्वर का कॉन्फ़िगरेशन एप्लिकेशन को मेल भेजने की अनुमति देता है। यदि आप इसे कॉन्फ़िगर नहीं करते हैं, तो OpenSupports द्वारा कोई ईमेल नहीं भेजा जाएगा।',
//ERRORS
'EMAIL_OR_PASSWORD': 'ईमेल या पासवर्ड अमान्य',
@ -355,5 +356,8 @@ export default {
'LEFT_EMPTY_DATABASE': 'स्वचालित डेटाबेस निर्माण के लिए खाली छोड़ दिया',
'REMEMBER_ME': 'मुझे याद रखना',
'EMAIL_LOWERCASE': 'ईमेल',
'PASSWORD_LOWERCASE': 'पासवर्ड'
'PASSWORD_LOWERCASE': 'पासवर्ड',
'TEST_SMTP_CONNECTION': 'परीक्षण एसएमटीपी कनेक्शन',
'SMTP_CONNECTION_SUCCESS': 'SMTP क्रेडेंशियल्स मान्य हं।',
'SMTP_CONNECTION_ERROR': 'एसएमटीपी सर्वर से कनेक्ट नहीं हो सकता'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'ここでは、電子メールまたはパスワードを変更してユーザーを編集できます。',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'ユーザシステムの使用を有効/無効にします。無効にすると、すべてのユーザーは削除されますが、チケットは保持されます。これを有効にすると、既存のチケットのユーザーが作成されます。',
'CSV_DESCRIPTION': 'CSVファイルには、電子メール、パスワード、名前の3つの列が必要です。行数に制限はありません。ファイル内で行ごとに1人ずつ作成されます',
'SMTP_SERVER_DESCRIPTION': 'SMTPサーバーの設定により、アプリケーションはメールを送信できます。 これを設定しないと、OpenSupportsから電子メールは送信されません。',
//ERRORS
'EMAIL_OR_PASSWORD': '電子メールまたはパスワードが無効です',
@ -355,6 +356,9 @@ export default {
'LEFT_EMPTY_DATABASE': '自動データベース作成のために空のままにする',
'REMEMBER_ME': '覚えている',
'EMAIL_LOWERCASE': 'Eメール',
'PASSWORD_LOWERCASE': 'パスワード'
'PASSWORD_LOWERCASE': 'パスワード',
'TEST_SMTP_CONNECTION': 'SMTP接続をテストする',
'SMTP_CONNECTION_SUCCESS': 'SMTP資格情報が有効です。',
'SMTP_CONNECTION_ERROR': 'SMTPサーバーに接続できません。'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'Aqui você pode editar seu usuário alterando seu e-mail ou sua senha.',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'Ativar / desativar o uso de um sistema de usuário. Se você desativá-lo, todos os usuários serão excluídos, mas os ingressos serão mantidos. Se você ativá-lo, os usuários de tickets existentes serão criados.',
'CSV_DESCRIPTION': 'O arquivo CSV deve ter 3 colunas: e-mail, senha, nome. Não há limite na contagem de linhas. Ele será criado um usuário por linha no arquivo.',
'SMTP_SERVER_DESCRIPTION': 'A configuração do servidor SMTP permite que o aplicativo envie e-mails. Se você não configurá-lo, nenhum e-mail será enviado pela OpenSupports.',
//ERRORS
'EMAIL_OR_PASSWORD': 'E-mail ou senha inválidos',
@ -355,5 +356,8 @@ export default {
'LEFT_EMPTY_DATABASE': 'Esquerda vazia para criação automática de banco de dados',
'REMEMBER_ME': 'Lembrar',
'EMAIL_LOWERCASE': 'email',
'PASSWORD_LOWERCASE': 'senha'
'PASSWORD_LOWERCASE': 'senha',
'TEST_SMTP_CONNECTION': 'Testar conexão SMTP',
'SMTP_CONNECTION_SUCCESS': 'As credenciais SMTP são válidas.',
'SMTP_CONNECTION_ERROR': 'Não pode se conectar ao servidor SMTP.'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'Здесь вы можете изменить своего пользователя, изменив свой адрес электронной почты или пароль.',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'Включить / отключить использование пользовательской системы. Если вы отключите его, все пользователи будут удалены. Если вы включите его, будут созданы пользователи существующих билетов.',
'CSV_DESCRIPTION': 'Файл CSV должен иметь 3 столбца: адрес электронной почты, пароль и имя. Количество строк не ограничено. В файле будет создан один пользователь для каждой строки.',
'SMTP_SERVER_DESCRIPTION': 'Конфигурация SMTP-сервера позволяет приложению отправлять письма. Если вы не настроите его, никакие электронные письма не будут отправлены OpenSupports.',
//ERRORS
'EMAIL_OR_PASSWORD': 'электронной почты или пароль недействительный',
@ -355,5 +356,8 @@ export default {
'LEFT_EMPTY_DATABASE': 'Пусто для автоматического создания базы данных',
'REMEMBER_ME': 'Запомнить',
'EMAIL_LOWERCASE': 'Эл. адрес',
'PASSWORD_LOWERCASE': 'пароль'
'PASSWORD_LOWERCASE': 'пароль',
'TEST_SMTP_CONNECTION': 'Тестирование SMTP-соединения',
'SMTP_CONNECTION_SUCCESS': 'Учетные данные SMTP действительны.',
'SMTP_CONNECTION_ERROR': 'Не удается подключиться к SMTP-серверу.'
};

View File

@ -285,6 +285,7 @@ export default {
'EDIT_PROFILE_VIEW_DESCRIPTION': 'Burada e-postanızı veya şifrenizi değiştirerek kullanıcıyı düzenleyebilirsiniz.',
'ENABLE_USER_SYSTEM_DESCRIPTION': 'Bir kullanıcı sisteminin kullanımını etkinleştirir / devre dışı bırakır. Devre dışı bırakırsanız, tüm kullanıcılar silinir ancak biletler muhafaza edilir. Etkinleştirirseniz, mevcut biletler kullanıcıları oluşturulur.',
'CSV_DESCRIPTION': 'CSV dosyasının 3 sütun olması gerekir: e-posta, şifre, ad. Satır sayısı sınırı yoktur. Dosya satır başına bir kullanıcı oluşturulur.',
'SMTP_SERVER_DESCRIPTION': 'SMTP sunucusunun yapılandırması, uygulamanın postalar göndermesine izin verir. Onu yapılandırmazsanız, OpenSupports tarafından hiçbir e-posta gönderilmeyecektir',
//ERRORS
'EMAIL_OR_PASSWORD': 'E-posta veya şifre geçersiz',
@ -355,5 +356,8 @@ export default {
'LEFT_EMPTY_DATABASE': 'Otomatik veritabanı oluşturulması için boş bırakıldı',
'REMEMBER_ME': 'Hatırlamak',
'EMAIL_LOWERCASE': 'e-posta',
'PASSWORD_LOWERCASE': 'parola'
'PASSWORD_LOWERCASE': 'parola',
'TEST_SMTP_CONNECTION': 'SMTP bağlantısını test et',
'SMTP_CONNECTION_SUCCESS': 'SMTP kimlik bilgileri geçerlidir.',
'SMTP_CONNECTION_ERROR': 'SMTP sunucusuna bağlanılamıyor.'
};

View File

@ -19,7 +19,8 @@ class ConfigReducer extends Reducer {
'CHANGE_LANGUAGE': this.onLanguageChange,
'INIT_CONFIGS_FULFILLED': this.onInitConfigs,
'CHECK_INSTALLATION_FULFILLED': this.onInstallationChecked,
'UPDATE_DATA_FULFILLED': this.onInitConfigs
'UPDATE_DATA_FULFILLED': this.onInitConfigs,
'UPDATE_USER_SYSTEM_SETTINGS': this.onUserSystemSettingsChange
};
}
@ -48,6 +49,13 @@ class ConfigReducer extends Reducer {
});
}
onUserSystemSettingsChange(state, payload) {
return _.extend({}, state, {
'user-system-enabled': !!(payload['user-system-enabled'] * 1),
'registration': !!(payload['registration'] * 1)
});
}
onInstallationChecked(state, payload) {
return _.extend({}, state, {
installedDone: true,

View File

@ -25,6 +25,7 @@ require_once 'system/delete-all-users.php';
require_once 'system/csv-import.php';
require_once 'system/backup-database.php';
require_once 'system/download.php';
require_once 'system/test-smtp.php';
$systemControllerGroup = new ControllerGroup();
$systemControllerGroup->setGroupPath('/system');
@ -55,5 +56,6 @@ $systemControllerGroup->addController(new DownloadController);
$systemControllerGroup->addController(new CSVImportController);
$systemControllerGroup->addController(new DisableUserSystemController);
$systemControllerGroup->addController(new EnableUserSystemController);
$systemControllerGroup->addController(new TestSMTPController);
$systemControllerGroup->finalize();

View File

@ -63,7 +63,7 @@ class DisableUserSystemController extends Controller {
$ticket->store();
}
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::USER_SYSTEM_DISABLED, [
'to' => $user->email,

View File

@ -87,7 +87,7 @@ class EnableUserSystemController extends Controller {
$userInstance->store();
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::USER_SYSTEM_ENABLED, [
'to' => $email,
'name' => $name,

View File

@ -60,18 +60,18 @@ class InitSettingsController extends Controller {
'language' => Controller::request('language'),
'recaptcha-public' => '',
'recaptcha-private' => '',
'no-reply-email' => 'noreply@opensupports.com',
'smtp-host' => 'localhost',
'smtp-port' => 7070,
'smtp-user' => '',
'smtp-pass' => '',
'no-reply-email' => Controller::request('no-reply-email'),
'smtp-host' => Controller::request('smtp-host'),
'smtp-port' => Controller::request('smtp-port'),
'smtp-user' => Controller::request('smtp-user'),
'smtp-pass' => Controller::request('smtp-password'),
'time-zone' => 0,
'maintenance-mode' => 0,
'layout' => 'boxed',
'allow-attachments' => 0,
'allow-attachments' => !!Controller::request('allow-attachments'),
'max-size' => 1024,
'title' => 'Support Center',
'url' => 'http://' . $_SERVER['HTTP_HOST'],
'title' => Controller::request('title') ? Controller::request('title') : 'Support Center',
'url' => Controller::request('url') ? Controller::request('url') : ('http://' . $_SERVER['HTTP_HOST']),
'registration' => !!Controller::request('registration'),
'user-system-enabled' => !!Controller::request('user-system-enabled'),
'last-stat-day' => date('YmdHi', strtotime(' -12 day ')),

View File

@ -0,0 +1,54 @@
<?php
use Respect\Validation\Validator as DataValidator;
/**
* @api {post} /system/test-smtp Test SMTP Connection
* @apiVersion 4.1.0
*
* @apiName Test SMTP Connection
*
* @apiGroup System
*
* @apiDescription Test if the given values connect correctly to a SMTP server.
*
* @apiPermission any
*
* @apiParam {String} smtp-host Host of the SMTP server.
* @apiParam {String} smtp-port Port of the SMTP server.
* @apiParam {String} smtp-user User for the SMTP server.
* @apiParam {String} smtp-pass Password for the SMTP server.
*
* @apiUse SMTP_CONNECTION
*
* @apiSuccess {Object} data Empty object
*
*/
class TestSMTPController extends Controller {
const PATH = '/test-smtp';
const METHOD = 'POST';
public function validations() {
return [
'permission' => 'any',
'requestData' => []
];
}
public function handler() {
$mailSender = MailSender::getInstance();
$mailSender->setConnectionSettings(
Controller::request('smtp-host'),
Controller::request('smtp-port'),
Controller::request('smtp-user'),
Controller::request('smtp-pass'),
Controller::request('no-reply-email')
);
if($mailSender->isConnected()) {
Response::respondSuccess();
} else {
throw new Exception(ERRORS::SMTP_CONNECTION);
}
}
}

View File

@ -113,7 +113,7 @@ class CloseController extends Controller {
}
private function sendMail() {
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::TICKET_CLOSED, [
'to' => ($this->ticket->author) ? $this->ticket->author->email : $this->ticket->authorEmail,

View File

@ -120,7 +120,7 @@ class CommentController extends Controller {
}
private function sendMail() {
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::TICKET_RESPONDED, [
'to' => ($this->ticket->author) ? $this->ticket->author->email : $this->ticket->authorEmail,

View File

@ -149,7 +149,7 @@ class CreateController extends Controller {
}
private function sendMail() {
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::TICKET_CREATED, [
'to' => $this->email,
@ -163,7 +163,7 @@ class CreateController extends Controller {
}
private function sendMailStaff($email) {
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::TICKET_CREATED_STAFF, [
'to' => $email,

View File

@ -45,7 +45,7 @@ class EditEmail extends Controller{
$user->email = $newEmail;
$user->store();
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate('USER_EMAIL', [
'to'=>$oldEmail,
'newemail'=>$user->email,

View File

@ -49,7 +49,7 @@ class EditPassword extends Controller {
$user->password = Hashing::hashPassword($newPassword);
$user->store();
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate('USER_PASSWORD', [
'to'=>$user->email,
'name'=>$user->name

View File

@ -86,7 +86,7 @@ class RecoverPasswordController extends Controller {
}
}
public function sendMail() {
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::USER_PASSWORD, [
'to' => $this->user->email,

View File

@ -71,7 +71,7 @@ class SendRecoverPasswordController extends Controller {
}
public function sendEmail() {
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::PASSWORD_FORGOT, [
'to' => $this->user->email,

View File

@ -102,7 +102,10 @@ class SignUpController extends Controller {
}
$userId = $this->createNewUserAndRetrieveId();
$this->sendRegistrationMail();
if(MailSender::getInstance()->isConnected()) {
$this->sendRegistrationMail();
}
Response::respondSuccess([
'userId' => $userId,
@ -128,14 +131,14 @@ class SignUpController extends Controller {
'tickets' => 0,
'email' => $this->userEmail,
'password' => Hashing::hashPassword($this->userPassword),
'verificationToken' => $this->verificationToken
'verificationToken' => (MailSender::getInstance()->isConnected()) ? $this->verificationToken : null
]);
return $userInstance->store();
}
public function sendRegistrationMail() {
$mailSender = new MailSender();
$mailSender = MailSender::getInstance();
$mailSender->setTemplate(MailTemplate::USER_SIGNUP, [
'to' => $this->userEmail,

View File

@ -171,6 +171,10 @@
* @apiDefine DATABASE_CREATION
* @apiError {String} DATABASE_CREATION It's a database creation error.
*/
/**
* @apiDefine SMTP_CONNECTION
* @apiError {String} SMTP_CONNECTION Could not connect with SMTP server.
*/
class ERRORS {
const INVALID_CREDENTIALS = 'INVALID_CREDENTIALS';
@ -216,4 +220,5 @@ class ERRORS {
const INVALID_FILE = 'INVALID_FILE';
const DATABASE_CONNECTION = 'DATABASE_CONNECTION';
const DATABASE_CREATION = 'DATABASE_CREATION';
const SMTP_CONNECTION = 'SMTP_CONNECTION';
}

View File

@ -2,15 +2,35 @@
class MailSender {
private $mailOptions = [];
public function __construct() {
$this->mailOptions['from'] = Setting::getSetting('no-reply-email')->value;
private $mailerInstance;
private static $instance = NULL;
public static function getInstance() {
if(MailSender::$instance === NULL) {
MailSender::$instance = new MailSender();
}
return MailSender::$instance;
}
private function __construct() {
$this->setConnectionSettings(
Setting::getSetting('smtp-host')->getValue(),
Setting::getSetting('smtp-port')->getValue(),
Setting::getSetting('smtp-user')->getValue(),
Setting::getSetting('smtp-pass')->getValue(),
Setting::getSetting('no-reply-email')->getValue()
);
}
public function setConnectionSettings($host, $port, $user, $pass, $noReplyEmail) {
$this->mailOptions['from'] = $noReplyEmail;
$this->mailOptions['fromName'] = 'OpenSupports';
$this->mailOptions['smtp-host'] = Setting::getSetting('smtp-host')->value;
$this->mailOptions['smtp-port'] = Setting::getSetting('smtp-port')->value;
$this->mailOptions['smtp-user'] = Setting::getSetting('smtp-user')->value;
$this->mailOptions['smtp-pass'] = Setting::getSetting('smtp-pass')->value;
$this->mailOptions['smtp-host'] = $host;
$this->mailOptions['smtp-port'] = $port;
$this->mailOptions['smtp-user'] = $user;
$this->mailOptions['smtp-pass'] = $pass;
}
public function setTemplate($type, $config) {
@ -21,32 +41,51 @@ class MailSender {
}
public function send() {
$mailer = new PHPMailer();
$mailerInstance = $this->getMailerInstance();
$mailer->From = $this->mailOptions['from'];
$mailer->FromName = $this->mailOptions['fromName'];
$mailer->addAddress($this->mailOptions['to']);
$mailer->Subject = $this->mailOptions['subject'];
$mailer->Body = $this->mailOptions['body'];
$mailer->isHTML(true);
if( !array_key_exists('to', $this->mailOptions) ||
!array_key_exists('subject', $this->mailOptions) ||
!array_key_exists('body', $this->mailOptions) ) {
throw new Exception('Mail sending data not available');
}
$mailer->isSMTP();
$mailer->SMTPAuth = true;
$mailer->Host = $this->mailOptions['smtp-host'];
$mailer->Port = $this->mailOptions['smtp-port'];
$mailer->Username = $this->mailOptions['smtp-user'];
$mailer->Password = $this->mailOptions['smtp-pass'];
$mailer->Timeout = 1000;
$mailer->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
$mailerInstance->addAddress($this->mailOptions['to']);
$mailerInstance->Subject = $this->mailOptions['subject'];
$mailerInstance->Body = $this->mailOptions['body'];
$mailerInstance->isHTML(true);
if ($mailer->smtpConnect()) {
$mailer->send();
if ($this->isConnected()) {
$mailerInstance->send();
}
}
public function isConnected() {
return $this->getMailerInstance()->smtpConnect();
}
private function getMailerInstance() {
if(!($this->mailerInstance instanceof PHPMailer)) {
$this->mailerInstance = new PHPMailer();
$this->mailerInstance->From = $this->mailOptions['from'];
$this->mailerInstance->FromName = $this->mailOptions['fromName'];
$this->mailerInstance->isSMTP();
$this->mailerInstance->SMTPAuth = true;
$this->mailerInstance->Host = $this->mailOptions['smtp-host'];
$this->mailerInstance->Port = $this->mailOptions['smtp-port'];
$this->mailerInstance->Username = $this->mailOptions['smtp-user'];
$this->mailerInstance->Password = $this->mailOptions['smtp-pass'];
$this->mailerInstance->Timeout = 1000;
$this->mailerInstance->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
}
return $this->mailerInstance;
}
}

View File

@ -18,4 +18,8 @@ class NullDataStore extends DataStore {
public function store() {
return null;
}
public function getValue() {
return null;
}
}

View File

@ -3,6 +3,12 @@ describe '/system/init-settings' do
result = request('/system/init-settings', {
'user-system-enabled' => true,
'registration' => true,
'title' => 'Support Center',
'smtp-host' => 'localhost',
'smtp-port' => 7070,
'smtp-user' => 'noreply@opensupports.com',
'smtp-password' => '',
'no-reply-email' => 'noreply@opensupports.com',
'language' => 'en'
})