mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add option in login call to check also for elopage account
This commit is contained in:
parent
e6c8fbed59
commit
93532004d5
@ -7,4 +7,7 @@ export default class UnsecureLoginArgs {
|
||||
|
||||
@Field(() => String)
|
||||
password: string
|
||||
|
||||
@Field(() => Boolean)
|
||||
hasElopage?: boolean
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ export class User {
|
||||
this.pubkey = json.public_hex
|
||||
this.language = json.language
|
||||
this.publisherId = json.publisher_id
|
||||
if (json.hasElopage) this.hasElopage = json.hasElopage
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
@ -74,4 +75,7 @@ export class User {
|
||||
|
||||
@Field(() => KlickTipp)
|
||||
klickTipp: KlickTipp
|
||||
|
||||
@Field(() => Boolean)
|
||||
hasElopage?: boolean
|
||||
}
|
||||
|
||||
@ -31,9 +31,16 @@ import { UserRepository } from '../../typeorm/repository/User'
|
||||
export class UserResolver {
|
||||
@Query(() => User)
|
||||
@UseMiddleware(klicktippNewsletterStateMiddleware)
|
||||
async login(@Args() { email, password }: UnsecureLoginArgs, @Ctx() context: any): Promise<User> {
|
||||
async login(
|
||||
@Args() { email, password, hasElopage }: UnsecureLoginArgs,
|
||||
@Ctx() context: any,
|
||||
): Promise<User> {
|
||||
email = email.trim().toLowerCase()
|
||||
const result = await apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', { email, password })
|
||||
const result = await apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', {
|
||||
email,
|
||||
password,
|
||||
hasElopage,
|
||||
})
|
||||
|
||||
// if there is no user, throw an authentication error
|
||||
if (!result.success) {
|
||||
|
||||
@ -40,10 +40,12 @@ with:
|
||||
"email": "max.musterman@gmail.de",
|
||||
"username": "Maxilein",
|
||||
"password": "123abcDE&"
|
||||
"hasElopage": true
|
||||
}
|
||||
```
|
||||
`username` or `email` must be present!
|
||||
If booth present, `email` will be used.
|
||||
`hasElopage`: optional, if set to true login will also check if user has an elopage account
|
||||
|
||||
### Response
|
||||
In case of success returns:
|
||||
@ -67,6 +69,7 @@ In case of success returns:
|
||||
"username": ""
|
||||
},
|
||||
"session_id": -127182,
|
||||
"hasElopage": tr
|
||||
"clientIP":"123.123.123.123"
|
||||
}
|
||||
```
|
||||
@ -86,6 +89,7 @@ In case of success returns:
|
||||
- `role`: role of user currently only "none" or "admin"
|
||||
- `username`: not used yet
|
||||
- `clientIP`: should be the same as where the js-client is running, else maybe a man-in-the-middle attacks is happening or
|
||||
- `hasElopage`: only present if hasElopage was set to true in request, true if user has an elopage account
|
||||
nginx was wrong configured.
|
||||
- `session_id`: can be also negative
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
|
||||
#include "../lib/DataTypeConverter.h"
|
||||
|
||||
#include "../model/table/ElopageBuy.h"
|
||||
|
||||
Poco::JSON::Object* JsonUnsecureLogin::handle(Poco::Dynamic::Var params)
|
||||
{
|
||||
|
||||
@ -23,6 +25,7 @@ Poco::JSON::Object* JsonUnsecureLogin::handle(Poco::Dynamic::Var params)
|
||||
std::string email;
|
||||
std::string username;
|
||||
std::string password;
|
||||
bool hasElopage = false;
|
||||
|
||||
// if is json object
|
||||
if (params.type() == typeid(Poco::JSON::Object::Ptr)) {
|
||||
@ -38,6 +41,11 @@ Poco::JSON::Object* JsonUnsecureLogin::handle(Poco::Dynamic::Var params)
|
||||
auto email_obj = paramJsonObject->get("email");
|
||||
auto username_obj = paramJsonObject->get("username");
|
||||
|
||||
auto hasElopage_obj = paramJsonObject->get("hasElopage");
|
||||
if (!hasElopage_obj.isEmpty()) {
|
||||
hasElopage_obj.convert(hasElopage);
|
||||
}
|
||||
|
||||
if (!email_obj.isEmpty()) {
|
||||
email_obj.convert(email);
|
||||
}
|
||||
@ -141,6 +149,10 @@ Poco::JSON::Object* JsonUnsecureLogin::handle(Poco::Dynamic::Var params)
|
||||
if(infos.size() > 0) {
|
||||
result->set("info", infos);
|
||||
}
|
||||
if (hasElopage) {
|
||||
auto elopage_buy = Poco::AutoPtr<model::table::ElopageBuy>(new model::table::ElopageBuy);
|
||||
result->set("hasElopage", elopage_buy->isExistInDB("email", mSession->getNewUser()->getModel()->getEmail()));
|
||||
}
|
||||
return result;
|
||||
default:
|
||||
result->set("state", "error");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user