Login/Auth and pariticipate. Telegram auth (wip)
This commit is contained in:
parent
91b4197b04
commit
4227389a67
14 changed files with 161 additions and 48 deletions
|
|
@ -118,10 +118,10 @@ Meteor.publish('activefiresmyloc', function activeInMyLoc(zoom, lat, lng, height
|
|||
check(height, NullOr(Number));
|
||||
check(width, NullOr(Number));
|
||||
// console.log(`Check active fires in ${lat},${lng} with zoom ${zoom} pixels in ${height}x${width} map`);
|
||||
if (lat === null || lng === null) {
|
||||
const location = localize();
|
||||
// console.log(`${location.latitude}, ${location.longitude}`);
|
||||
return activefires(zoom, location.latitude, location.longitude, height, width);
|
||||
if (lat && lng) {
|
||||
return activefires(zoom, lat, lng, height, width);
|
||||
}
|
||||
return activefires(zoom, lat, lng, height, width);
|
||||
const location = localize();
|
||||
// console.log(`${location.latitude}, ${location.longitude}`);
|
||||
return activefires(zoom, location.latitude, location.longitude, height, width);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { defaultCreatedAt, defaultUpdateAt } from '/imports/api/Utility/Utils.js';
|
||||
import i18n from 'i18next';
|
||||
|
||||
const schemaUserProfile = new SimpleSchema({
|
||||
// name: { type: String, optional: true },
|
||||
name: Object,
|
||||
/* Our users has a name of type Object while Google Service, for instance, not */
|
||||
/* name: { type: String, optional: true }, */
|
||||
/* name: Object,
|
||||
'name.first': String,
|
||||
'name.last': String,
|
||||
'name.last': String, */
|
||||
lang: { type: String, optional: true },
|
||||
telegramChatId: { type: Number, optional: true },
|
||||
telegramUsername: { type: String, optional: true },
|
||||
|
|
|
|||
|
|
@ -2,14 +2,18 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import { Route, Redirect } from 'react-router-dom';
|
||||
|
||||
const Public = ({ loggingIn, authenticated, component, path, exact, ...rest }) => (
|
||||
const Public = ({
|
||||
loggingIn, authenticated, component, location, path, exact, ...rest
|
||||
}) => (
|
||||
<Route
|
||||
path={path}
|
||||
exact={exact}
|
||||
render={props => (
|
||||
!authenticated ?
|
||||
(React.createElement(component, { ...props, ...rest, loggingIn, authenticated })) :
|
||||
(<Redirect to="/subscriptions" />)
|
||||
(React.createElement(component, {
|
||||
...props, ...rest, loggingIn, authenticated
|
||||
})) :
|
||||
(<Redirect to={{ pathname: '/subscriptions', state: location.state }} />)
|
||||
)}
|
||||
/>
|
||||
);
|
||||
|
|
@ -17,7 +21,7 @@ const Public = ({ loggingIn, authenticated, component, path, exact, ...rest }) =
|
|||
Public.propTypes = {
|
||||
loggingIn: PropTypes.bool.isRequired,
|
||||
authenticated: PropTypes.bool.isRequired,
|
||||
component: PropTypes.func.isRequired,
|
||||
component: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default Public;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class SelectionMap extends Component {
|
|||
|
||||
onFstBtn() {
|
||||
this.props.onFstBtn({
|
||||
location: { lat: this.state.center[0], lon: this.state.center[1] },
|
||||
location: { lat: this.state.marker[0], lon: this.state.marker[1] },
|
||||
distance: this.state.distance
|
||||
});
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ class SelectionMap extends Component {
|
|||
|
||||
fit() {
|
||||
// console.log("fit!");
|
||||
if (this.props.currentSubs.length > 0 && this.state.subsFit) {
|
||||
if (this.props.currentSubs.length > 0 && this.state.subsFit && this.props.action !== action.add) {
|
||||
// has autofit, do nothing
|
||||
} else if (this.selectionMap && this.distanceCircle) {
|
||||
if (!this.getMap().getBounds().contains(this.distanceCircle.leafletElement.getBounds())) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ class FireSubscription extends React.Component {
|
|||
zoom: this.props.zoom,
|
||||
distance: this.props.distance
|
||||
};
|
||||
// console.log(this.props.location.state);
|
||||
if (props.location) {
|
||||
console.log(props.location.state);
|
||||
}
|
||||
console.log(this.state);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ class FiresMap extends React.Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
viewport: this.props.viewport,
|
||||
viewport: {
|
||||
center: props.center,
|
||||
zoom: props.zoom
|
||||
},
|
||||
useMarkers: false,
|
||||
showSubsUnion: true
|
||||
};
|
||||
|
|
@ -214,7 +217,8 @@ FiresMap.propTypes = {
|
|||
activefires: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
firealerts: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
activefirestotal: PropTypes.number.isRequired,
|
||||
viewport: PropTypes.object.isRequired,
|
||||
center: PropTypes.arrayOf(PropTypes.number),
|
||||
zoom: PropTypes.number,
|
||||
t: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
|
|
@ -224,6 +228,7 @@ export default translate([], { wait: true })(withTracker(() => {
|
|||
Meteor.autorun(() => {
|
||||
if (geolocation.get() && init) {
|
||||
center.set(geolocation.get());
|
||||
// console.log(`Geolocation ${geolocation.get()}`);
|
||||
init = false;
|
||||
}
|
||||
if (mapSize.get()) {
|
||||
|
|
@ -258,9 +263,7 @@ export default translate([], { wait: true })(withTracker(() => {
|
|||
firealerts: FireAlertsCollection.find().fetch().map(doc => (
|
||||
{ _id: doc._id, lat: doc.location.lat, lon: doc.location.lon }
|
||||
)),
|
||||
viewport: {
|
||||
center: geolocation.get(),
|
||||
zoom: zoom.get()
|
||||
}
|
||||
center: geolocation.get(),
|
||||
zoom: zoom.get()
|
||||
};
|
||||
})(FiresMap));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class Login extends React.Component {
|
|||
super(props);
|
||||
this.t = props.t;
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
// console.log(this.props.location.state);
|
||||
console.log(this.props.location.state);
|
||||
this.state = props.location.state;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
@ -110,6 +111,7 @@ class Login extends React.Component {
|
|||
Login.propTypes = {
|
||||
history: PropTypes.object.isRequired,
|
||||
t: PropTypes.func.isRequired,
|
||||
location: PropTypes.object
|
||||
};
|
||||
|
||||
export default translate([], { wait: true })(Login);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,15 @@ class NewSubscription extends Component {
|
|||
const pushState = this.props.location.state;
|
||||
this.state = {
|
||||
center: pushState ? pushState.center : [null, null],
|
||||
zoom: pushState ? pushState.zoom : null
|
||||
zoom: pushState ? pushState.zoom : null,
|
||||
// we have a subscription from home?
|
||||
doc: pushState && pushState.location ? {
|
||||
location: {
|
||||
lat: pushState.location.lat,
|
||||
lot: pushState.location.lon
|
||||
},
|
||||
distance: pushState.distance
|
||||
} : undefined
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -24,6 +32,7 @@ class NewSubscription extends Component {
|
|||
history={history}
|
||||
center={this.state.center}
|
||||
zoom={this.state.zoom}
|
||||
doc={this.state.doc}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint-disable react/jsx-indent-props */
|
||||
|
||||
import React from 'react';
|
||||
import { Row, FormGroup, ControlLabel, Button } from 'react-bootstrap';
|
||||
import Col from '../../components/Col/Col';
|
||||
|
|
@ -6,6 +8,8 @@ import { Link } from 'react-router-dom';
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Accounts } from 'meteor/accounts-base';
|
||||
import { Bert } from 'meteor/themeteorchef:bert';
|
||||
import randomHex from 'random-hexadecimal';
|
||||
import Icon from '../../components/Icon/Icon';
|
||||
import OAuthLoginButtons from '../../components/OAuthLoginButtons/OAuthLoginButtons';
|
||||
import InputHint from '../../components/InputHint/InputHint';
|
||||
import AccountPageFooter from '../../components/AccountPageFooter/AccountPageFooter';
|
||||
|
|
@ -64,7 +68,7 @@ class Signup extends React.Component {
|
|||
}
|
||||
|
||||
handleSubmit() {
|
||||
const { history } = this.props;
|
||||
const { history, t } = this.props;
|
||||
|
||||
Accounts.createUser({
|
||||
email: this.emailAddress.value,
|
||||
|
|
@ -80,31 +84,35 @@ class Signup extends React.Component {
|
|||
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
||||
} else {
|
||||
Meteor.call('users.sendVerificationEmail');
|
||||
Bert.alert('Welcome!', 'success');
|
||||
Bert.alert(t('Bienvenid@!'), 'success');
|
||||
history.push('/subscriptions');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { t, history } = this.props;
|
||||
return (<div className="Signup">
|
||||
<Row className="align-items-center justify-content-center">
|
||||
<Col xs={12} sm={6} md={5} lg={4}>
|
||||
<h4 className="page-header">{this.t('Registrarse')}</h4>
|
||||
<h4 className="page-header">{t('Registrarse')}</h4>
|
||||
<Row>
|
||||
{/* <Col xs={12}>
|
||||
<button
|
||||
className={`btn btn-block btn-raised btn-primary OAuthLoginButtonDis OAuthLoginButton-telegram`}
|
||||
type="button" onClick={() => handleLogin(service, callback)}>
|
||||
<span><Icon icon="telegram" /> Usa nuestro bot de Telegram</span>
|
||||
</button>
|
||||
</Col> */}
|
||||
<Col xs={12}>
|
||||
<button
|
||||
className="btn btn-block btn-raised btn-primary OAuthLoginButtonDis OAuthLoginButton-telegram"
|
||||
type="button"
|
||||
onClick={() => { const hex = randomHex({ max: 20 }); window.open(`https://t.me/TodosContraElFuego_bot?start=${hex}`); }}
|
||||
>
|
||||
<span><Icon icon="telegram" /> {t('Iniciar sesión con Telegram')}</span>
|
||||
</button>
|
||||
</Col>
|
||||
<Col xs={12}>
|
||||
<OAuthLoginButtons
|
||||
services={['telegram', 'google']}
|
||||
emailMessage={{
|
||||
offset: 97,
|
||||
text: this.t('o regístrate con un correo')
|
||||
text: t('o regístrate con un correo')
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
|
|
@ -113,7 +121,7 @@ class Signup extends React.Component {
|
|||
<Row>
|
||||
<Col xs={6}>
|
||||
<FormGroup>
|
||||
<ControlLabel>{this.t('Nombre')}</ControlLabel>
|
||||
<ControlLabel>{t('Nombre')}</ControlLabel>
|
||||
<input
|
||||
type="text"
|
||||
name="firstName"
|
||||
|
|
@ -124,7 +132,7 @@ class Signup extends React.Component {
|
|||
</Col>
|
||||
<Col xs={6}>
|
||||
<FormGroup>
|
||||
<ControlLabel>{this.t('Apellidos')}</ControlLabel>
|
||||
<ControlLabel>{t('Apellidos')}</ControlLabel>
|
||||
<input
|
||||
type="text"
|
||||
name="lastName"
|
||||
|
|
@ -135,7 +143,7 @@ class Signup extends React.Component {
|
|||
</Col>
|
||||
</Row>
|
||||
<FormGroup>
|
||||
<ControlLabel>{this.t('Correo electrónico')}</ControlLabel>
|
||||
<ControlLabel>{t('Correo electrónico')}</ControlLabel>
|
||||
<input
|
||||
type="email"
|
||||
name="emailAddress"
|
||||
|
|
@ -144,18 +152,18 @@ class Signup extends React.Component {
|
|||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<ControlLabel>{this.t('Contraseña')}</ControlLabel>
|
||||
<ControlLabel>{t('Contraseña')}</ControlLabel>
|
||||
<input
|
||||
type="password"
|
||||
name="password"
|
||||
ref={password => (this.password = password)}
|
||||
className="form-control"
|
||||
/>
|
||||
<InputHint>{this.t('Usa al menos seis caracteres.')}</InputHint>
|
||||
<InputHint>{t('Usa al menos seis caracteres.')}</InputHint>
|
||||
</FormGroup>
|
||||
<Button type="submit" bsStyle="success">{this.t('Registrarse')}</Button>
|
||||
<Button type="submit" bsStyle="success">{t('Registrarse')}</Button>
|
||||
<AccountPageFooter>
|
||||
<p>{this.t('¿Ya tienes un cuenta?')} <Link to={{ pathname: '/login', state: this.state }} >{this.t('Iniciar sesión')}</Link>.</p>
|
||||
<p>{t('¿Ya tienes un cuenta?')} <Link to={{ pathname: '/login', state: this.state }} >{t('Iniciar sesión')}</Link>.</p>
|
||||
</AccountPageFooter>
|
||||
</form>
|
||||
</Col>
|
||||
|
|
@ -165,7 +173,8 @@ class Signup extends React.Component {
|
|||
}
|
||||
|
||||
Signup.propTypes = {
|
||||
history: PropTypes.object.isRequired
|
||||
history: PropTypes.object.isRequired,
|
||||
location: PropTypes.object
|
||||
};
|
||||
|
||||
export default translate([], { wait: true })(Signup);
|
||||
|
|
|
|||
|
|
@ -19,9 +19,16 @@ class Subscriptions extends Component {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
this.t = props.t;
|
||||
this.state = {
|
||||
action: action.view
|
||||
};
|
||||
if (props.location.state) {
|
||||
const received = props.location.state;
|
||||
props.history.push(`${this.props.match.url}/new`, {
|
||||
location: received.location,
|
||||
distance: received.distance,
|
||||
center: [received.location.lat, received.location.lon]
|
||||
});
|
||||
}
|
||||
this.state = {};
|
||||
this.state.action = action.view;
|
||||
this.onViewportChanged = this.onViewportChanged.bind(this);
|
||||
this.onFstBtn = this.onFstBtn.bind(this);
|
||||
this.onSndBtn = this.onSndBtn.bind(this);
|
||||
|
|
@ -109,7 +116,8 @@ Subscriptions.propTypes = {
|
|||
subscriptions: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
match: PropTypes.object.isRequired,
|
||||
t: PropTypes.func.isRequired,
|
||||
history: PropTypes.object.isRequired
|
||||
history: PropTypes.object.isRequired,
|
||||
location: PropTypes.object
|
||||
};
|
||||
|
||||
export default translate([], { wait: true })(withTracker(() => {
|
||||
|
|
|
|||
|
|
@ -190,6 +190,7 @@ div.section.contact ul.list-social li.social-google-plus a:hover {
|
|||
font-size: 16px;
|
||||
}
|
||||
|
||||
.OAuthLoginButton-telegram,
|
||||
.OAuthLoginButtons > .btn {
|
||||
letter-spacing: inherit;
|
||||
text-transform: none;
|
||||
|
|
|
|||
70
package-lock.json
generated
70
package-lock.json
generated
|
|
@ -2342,6 +2342,11 @@
|
|||
"integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==",
|
||||
"dev": true
|
||||
},
|
||||
"clamp": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/clamp/-/clamp-1.0.1.tgz",
|
||||
"integrity": "sha1-ZqDmQBGBbjcZaCj9yMjBRzEshjQ="
|
||||
},
|
||||
"classnames": {
|
||||
"version": "2.2.5",
|
||||
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.5.tgz",
|
||||
|
|
@ -5250,6 +5255,11 @@
|
|||
"number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz"
|
||||
}
|
||||
},
|
||||
"is-function": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz",
|
||||
"integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU="
|
||||
},
|
||||
"is-glob": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz",
|
||||
|
|
@ -5270,6 +5280,11 @@
|
|||
"xtend": "4.0.1"
|
||||
}
|
||||
},
|
||||
"is-nil": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-nil/-/is-nil-1.0.1.tgz",
|
||||
"integrity": "sha1-LauingtYUGOHXntTnQcfWxWTeWk="
|
||||
},
|
||||
"is-number": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
|
||||
|
|
@ -5279,6 +5294,11 @@
|
|||
"kind-of": "3.2.2"
|
||||
}
|
||||
},
|
||||
"is-object": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz",
|
||||
"integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA="
|
||||
},
|
||||
"is-path-cwd": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
|
||||
|
|
@ -7615,6 +7635,11 @@
|
|||
"tmpl": "1.0.4"
|
||||
}
|
||||
},
|
||||
"max-safe-int": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/max-safe-int/-/max-safe-int-1.0.0.tgz",
|
||||
"integrity": "sha1-RPuo7Jk97ZH7LFo15xz5yfNpzlI="
|
||||
},
|
||||
"maxmind": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/maxmind/-/maxmind-2.3.0.tgz",
|
||||
|
|
@ -9624,6 +9649,33 @@
|
|||
"ret": "0.1.15"
|
||||
}
|
||||
},
|
||||
"random-hexadecimal": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/random-hexadecimal/-/random-hexadecimal-1.0.3.tgz",
|
||||
"integrity": "sha1-vg80y8Jbnz21I8NZpUarl//zz1c=",
|
||||
"requires": {
|
||||
"random-natural": "1.0.3"
|
||||
}
|
||||
},
|
||||
"random-integral": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/random-integral/-/random-integral-1.0.3.tgz",
|
||||
"integrity": "sha1-j/PBF1ZcmgS2bd1VnzrtKb0PD2w=",
|
||||
"requires": {
|
||||
"clamp": "1.0.1",
|
||||
"max-safe-int": "1.0.0",
|
||||
"to-integer": "1.0.1"
|
||||
}
|
||||
},
|
||||
"random-natural": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/random-natural/-/random-natural-1.0.3.tgz",
|
||||
"integrity": "sha1-7yhhWwPCy3Gq6/fyT0hyZqRDxcA=",
|
||||
"requires": {
|
||||
"max-safe-int": "1.0.0",
|
||||
"random-integral": "1.0.3"
|
||||
}
|
||||
},
|
||||
"randomatic": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
|
||||
|
|
@ -11301,6 +11353,24 @@
|
|||
"integrity": "sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=",
|
||||
"dev": true
|
||||
},
|
||||
"to-integer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-integer/-/to-integer-1.0.1.tgz",
|
||||
"integrity": "sha1-URrUHc5qk3MKjztuNaFk/YKUZNo=",
|
||||
"requires": {
|
||||
"is-function": "1.0.1",
|
||||
"is-nil": "1.0.1",
|
||||
"is-object": "1.0.1",
|
||||
"is-symbol": "1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-symbol": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
|
||||
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI="
|
||||
}
|
||||
}
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz",
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
"nodemailer": "^4.4.1",
|
||||
"popper.js": "^1.12.7",
|
||||
"prop-types": "^15.6.0",
|
||||
"random-hexadecimal": "^1.0.3",
|
||||
"rc-slider": "^8.5.0",
|
||||
"rc-tooltip": "^3.7.0",
|
||||
"react": "^16.0.0",
|
||||
|
|
|
|||
|
|
@ -180,5 +180,8 @@
|
|||
"No": "No",
|
||||
"Sobre los datos y imágenes usados": "Sobre los datos y imágenes usados",
|
||||
"Términos de Servicio": "Términos de Servicio",
|
||||
"Política de Privacidad": "Política de Privacidad"
|
||||
"Política de Privacidad": "Política de Privacidad",
|
||||
"No estás suscrito a fuegos en ninguna zona": "No estás suscrito a fuegos en ninguna zona",
|
||||
"Iniciar sesión con Telegram":
|
||||
"Iniciar sesión con Telegram"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue