diff options
Diffstat (limited to 'linden/indra/newview/llloginhandler.cpp')
-rw-r--r-- | linden/indra/newview/llloginhandler.cpp | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/linden/indra/newview/llloginhandler.cpp b/linden/indra/newview/llloginhandler.cpp new file mode 100644 index 0000000..f409ddc --- /dev/null +++ b/linden/indra/newview/llloginhandler.cpp | |||
@@ -0,0 +1,160 @@ | |||
1 | /** | ||
2 | * @file llloginhandler.cpp | ||
3 | * @brief Handles filling in the login panel information from a SLURL | ||
4 | * such as secondlife:///app/login?first=Bob&last=Dobbs | ||
5 | * | ||
6 | * $LicenseInfo:firstyear=2008&license=viewergpl$ | ||
7 | * | ||
8 | * Copyright (c) 2008-2009, Linden Research, Inc. | ||
9 | * | ||
10 | * Second Life Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
12 | * to you under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
15 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
16 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
17 | * | ||
18 | * There are special exceptions to the terms and conditions of the GPL as | ||
19 | * it is applied to this Source Code. View the full text of the exception | ||
20 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
21 | * online at | ||
22 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
23 | * | ||
24 | * By copying, modifying or distributing this software, you acknowledge | ||
25 | * that you have read and understood your obligations described above, | ||
26 | * and agree to abide by those obligations. | ||
27 | * | ||
28 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
29 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
30 | * COMPLETENESS OR PERFORMANCE. | ||
31 | * $/LicenseInfo$ | ||
32 | */ | ||
33 | #include "llviewerprecompiledheaders.h" | ||
34 | |||
35 | #include "llloginhandler.h" | ||
36 | |||
37 | // viewer includes | ||
38 | #include "llpanellogin.h" // save_password_to_disk() | ||
39 | #include "llstartup.h" // getStartupState() | ||
40 | #include "llurlsimstring.h" | ||
41 | #include "llviewercontrol.h" // gSavedSettings | ||
42 | #include "llviewernetwork.h" // EGridInfo | ||
43 | |||
44 | // library includes | ||
45 | #include "llmd5.h" | ||
46 | |||
47 | |||
48 | // Must have instance to auto-register with LLCommandDispatcher | ||
49 | LLLoginHandler gLoginHandler; | ||
50 | |||
51 | |||
52 | //parses the input url and returns true if afterwards | ||
53 | //a web-login-key, firstname and lastname is set | ||
54 | bool LLLoginHandler::parseDirectLogin(std::string url) | ||
55 | { | ||
56 | LLURI uri(url); | ||
57 | parse(uri.queryMap()); | ||
58 | |||
59 | if (mWebLoginKey.isNull() || | ||
60 | mFirstName.empty() || | ||
61 | mLastName.empty()) | ||
62 | { | ||
63 | return false; | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | return true; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | |||
72 | void LLLoginHandler::parse(const LLSD& queryMap) | ||
73 | { | ||
74 | mWebLoginKey = queryMap["web_login_key"].asUUID(); | ||
75 | mFirstName = queryMap["first_name"].asString(); | ||
76 | mLastName = queryMap["last_name"].asString(); | ||
77 | |||
78 | |||
79 | EGridInfo grid_choice = GRID_INFO_NONE; | ||
80 | if (queryMap["grid"].asString() == "sl beta grid") | ||
81 | { | ||
82 | grid_choice = GRID_INFO_ADITI; | ||
83 | } | ||
84 | else if (queryMap["grid"].asString() == "sl main grid") | ||
85 | { | ||
86 | grid_choice = GRID_INFO_AGNI; | ||
87 | } | ||
88 | |||
89 | if(grid_choice != GRID_INFO_NONE) | ||
90 | { | ||
91 | LLViewerLogin::getInstance()->setGridChoice(grid_choice); | ||
92 | } | ||
93 | |||
94 | std::string startLocation = queryMap["location"].asString(); | ||
95 | |||
96 | if (startLocation == "specify") | ||
97 | { | ||
98 | LLURLSimString::setString(queryMap["region"].asString()); | ||
99 | } | ||
100 | else if (startLocation == "home") | ||
101 | { | ||
102 | gSavedSettings.setBOOL("LoginLastLocation", FALSE); | ||
103 | LLURLSimString::setString(LLStringUtil::null); | ||
104 | } | ||
105 | else if (startLocation == "last") | ||
106 | { | ||
107 | gSavedSettings.setBOOL("LoginLastLocation", TRUE); | ||
108 | LLURLSimString::setString(LLStringUtil::null); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | bool LLLoginHandler::handle(const LLSD& tokens, | ||
113 | const LLSD& query_map, | ||
114 | LLWebBrowserCtrl* web) | ||
115 | { | ||
116 | parse(query_map); | ||
117 | |||
118 | //if we haven't initialized stuff yet, this is | ||
119 | //coming in from the GURL handler, just parse | ||
120 | if (STATE_FIRST == LLStartUp::getStartupState()) | ||
121 | { | ||
122 | return true; | ||
123 | } | ||
124 | |||
125 | std::string password = query_map["password"].asString(); | ||
126 | |||
127 | if (!password.empty()) | ||
128 | { | ||
129 | gSavedSettings.setBOOL("RememberPassword", TRUE); | ||
130 | |||
131 | if (password.substr(0,3) != "$1$") | ||
132 | { | ||
133 | LLMD5 pass((unsigned char*)password.c_str()); | ||
134 | char md5pass[33]; /* Flawfinder: ignore */ | ||
135 | pass.hex_digest(md5pass); | ||
136 | std::string hashed_password = ll_safe_string(md5pass, 32); | ||
137 | LLStartUp::savePasswordToDisk(hashed_password); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | |||
142 | if (LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP) //on splash page | ||
143 | { | ||
144 | if (!mFirstName.empty() || !mLastName.empty()) | ||
145 | { | ||
146 | // Fill in the name, and maybe the password | ||
147 | LLPanelLogin::setFields(mFirstName, mLastName, password); | ||
148 | } | ||
149 | |||
150 | if (mWebLoginKey.isNull()) | ||
151 | { | ||
152 | LLPanelLogin::loadLoginPage(); | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | LLStartUp::setStartupState( STATE_LOGIN_CLEANUP ); | ||
157 | } | ||
158 | } | ||
159 | return true; | ||
160 | } | ||